> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-hi/language-models/deepseek-coder.md).

# DeepSeek Coder

Clore.ai पर DeepSeek Coder के साथ सर्वोत्तम-श्रेणी का कोड जनरेशन

{% hint style="info" %}
**नए संस्करण उपलब्ध हैं!** [**DeepSeek-R1**](/guides/guides_v2-hi/language-models/deepseek-r1.md) (तर्क + कोडिंग) और [**DeepSeek-V3**](/guides/guides_v2-hi/language-models/deepseek-v3.md) (सामान्य प्रयोजन) काफी अधिक सक्षम हैं। यह भी देखें [**Qwen2.5-Coder**](/guides/guides_v2-hi/language-models/qwen25.md) एक मजबूत कोडिंग विकल्प के लिए।
{% endhint %}

DeepSeek Coder मॉडलों के साथ सर्वोत्तम-श्रेणी का कोड जनरेशन।

{% hint style="success" %}
सभी उदाहरण GPU सर्वरों पर चलाए जा सकते हैं, जिन्हें किराए पर लिया गया है [CLORE.AI मार्केटप्लेस](https://clore.ai/marketplace).
{% endhint %}

## CLORE.AI पर किराए पर लेना

1. विज़िट करें [CLORE.AI मार्केटप्लेस](https://clore.ai/marketplace)
2. GPU प्रकार, VRAM और कीमत के अनुसार फ़िल्टर करें
3. चुनें **ऑन-डिमांड** (स्थिर दर) या **स्पॉट** (बोली मूल्य)
4. अपना ऑर्डर कॉन्फ़िगर करें:
   * Docker इमेज चुनें
   * पोर्ट सेट करें (SSH के लिए TCP, वेब UI के लिए HTTP)
   * यदि आवश्यक हो तो environment variables जोड़ें
   * स्टार्टअप कमांड दर्ज करें
5. भुगतान चुनें: **CLORE**, **BTC**या **USDT/USDC**
6. ऑर्डर बनाएं और डिप्लॉयमेंट की प्रतीक्षा करें

### अपने सर्वर तक पहुँचें

* कनेक्शन विवरण यहाँ खोजें **मेरे ऑर्डर**
* वेब इंटरफ़ेस: HTTP पोर्ट URL का उपयोग करें
* SSH: `ssh -p <port> root@<proxy-address>`

## DeepSeek Coder क्या है?

DeepSeek Coder प्रदान करता है:

* अत्याधुनिक कोड जनरेशन
* 338 प्रोग्रामिंग भाषाएँ
* बीच में भरने का समर्थन
* रिपॉज़िटरी-स्तरीय समझ

## मॉडल वेरिएंट

| मॉडल                | पैरामीटर | VRAM  | संदर्भ |
| ------------------- | -------- | ----- | ------ |
| DeepSeek-Coder-1.3B | 1.3B     | 3GB   | 16K    |
| DeepSeek-Coder-6.7B | 6.7B     | 8GB   | 16K    |
| DeepSeek-Coder-33B  | 33B      | 40GB  | 16K    |
| DeepSeek-Coder-V2   | 16B/236B | 20GB+ | 128K   |

## त्वरित डिप्लॉय

**Docker इमेज:**

```
pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime
```

**पोर्ट:**

```
22/tcp
8000/http
```

**कमांड:**

```bash
pip install vllm && \
vllm serve deepseek-ai/deepseek-coder-6.7b-instruct --port 8000
```

## अपनी सेवा तक पहुँचना

डिप्लॉयमेंट के बाद, अपना `http_pub` URL यहाँ **मेरे ऑर्डर**:

1. पर जाएँ **मेरे ऑर्डर** पेज
2. अपने ऑर्डर पर क्लिक करें
3. खोजें `http_pub` URL (उदा., `abc123.clorecloud.net`)

उपयोग करें `https://YOUR_HTTP_PUB_URL` की बजाय `localhost` नीचे दिए गए उदाहरणों में।

## Ollama का उपयोग

```bash

# DeepSeek Coder चलाएँ
ollama run deepseek-coder

# विशिष्ट आकार
ollama run deepseek-coder:1.3b
ollama run deepseek-coder:6.7b
ollama run deepseek-coder:33b

# V2 (नवीनतम)
ollama run deepseek-coder-v2
```

## इंस्टॉलेशन

```bash
pip install transformers accelerate torch
```

## कोड जनरेशन

```python
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_id = "deepseek-ai/deepseek-coder-6.7b-instruct"

tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True
)

messages = [
    {"role": "user", "content": """
एक REST API क्लाइंट के लिए Python क्लास लिखें, जिसमें:
- प्रमाणीकरण समर्थन
- एक्सपोनेंशियल बैकऑफ़ के साथ पुनः प्रयास लॉजिक
- अनुरोध/प्रतिक्रिया लॉगिंग
"""}
]

inputs = tokenizer.apply_chat_template(
    messages,
    add_generation_prompt=True,
    return_tensors="pt"
).to("cuda")

outputs = model.generate(
    inputs,
    max_new_tokens=1024,
    temperature=0.2,
    do_sample=True
)

print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))
```

## बीच में भरना (FIM)

```python
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_id = "deepseek-ai/deepseek-coder-6.7b-base"

tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True
)

# बीच में भरने का प्रारूप
prefix = """def calculate_statistics(data):
    \"\"\"एक सूची का माध्य, माध्यिका और मानक विचलन गणना करें।\"\"\"
    import statistics

    mean = statistics.mean(data)
"""

suffix = """
    return {
        'mean': mean,
        'median': median,
        'std': std
    }
"""

# FIM टोकन
prompt = f"<｜fim▁begin｜>{prefix}<｜fim▁hole｜>{suffix}<｜fim▁end｜>"

inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=128)

print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```

## DeepSeek-Coder-V2

नवीनतम और सबसे शक्तिशाली:

```python
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_id = "deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct"

tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True
)

messages = [
    {"role": "user", "content": "Python में एक thread-safe LRU cache लागू करें"}
]

inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to("cuda")
outputs = model.generate(inputs, max_new_tokens=1024, temperature=0.2)
print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))
```

## vLLM सर्वर

```bash
vllm serve deepseek-ai/deepseek-coder-6.7b-instruct \
    --port 8000 \
    --dtype bfloat16 \
    --max-model-len 16384 \
    --trust-remote-code
```

### API उपयोग

```python
from openai import OpenAI

client = OpenAI(base_url="http://localhost:8000/v1", api_key="x")

response = client.chat.completions.create(
    model="deepseek-ai/deepseek-coder-6.7b-instruct",
    messages=[
        {"role": "system", "content": "आप एक विशेषज्ञ प्रोग्रामर हैं।"},
        {"role": "user", "content": "FastAPI वेबसोकेट सर्वर लिखें"}
    ],
    temperature=0.2,
    max_tokens=1500
)

print(response.choices[0].message.content)
```

## कोड समीक्षा

````python
code_to_review = """
def process_data(data):
    result = []
    for i in range(len(data)):
        if data[i] > 0:
            result.append(data[i] * 2)
    return result
"""

messages = [
    {"role": "user", "content": f"""
इस कोड की समीक्षा करें और सुधार सुझाएँ:

```python
{code_to_review}
````

इन पर ध्यान दें:

1. प्रदर्शन
2. पठनीयता
3. सर्वोत्तम अभ्यास """} ]

````

## बग सुधार

```python
buggy_code = """
def merge_sorted_lists(list1, list2):
    result = []
    i = j = 0
    while i < len(list1) and j < len(list2):
        if list1[i] < list2[j]:
            result.append(list1[i])
            i += 1
        else:
            result.append(list2[j])
    return result
"""

messages = [
    {"role": "user", "content": f"""
इस कोड में बग खोजें और ठीक करें:

```python
{buggy_code}
````

"""} ]

````

## Gradio इंटरफ़ेस

```python
import gradio as gr
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_id = "deepseek-ai/deepseek-coder-6.7b-instruct"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_id, torch_dtype=torch.bfloat16, device_map="auto", trust_remote_code=True
)

def generate_code(prompt, temperature, max_tokens):
    messages = [{"role": "user", "content": prompt}]
    inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to("cuda")
    outputs = model.generate(inputs, max_new_tokens=max_tokens, temperature=temperature, do_sample=True)
    return tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True)

demo = gr.Interface(
    fn=generate_code,
    inputs=[
        gr.Textbox(label="प्रॉम्प्ट", lines=5, placeholder="आपको जिस कोड की आवश्यकता है उसका वर्णन करें..."),
        gr.Slider(0.1, 1.0, value=0.2, label="तापमान"),
        gr.Slider(256, 2048, value=1024, step=128, label="अधिकतम टोकन")
    ],
    outputs=gr.Code(language="python", label="जनरेट किया गया कोड"),
    title="DeepSeek Coder"
)

demo.launch(server_name="0.0.0.0", server_port=7860)
````

## प्रदर्शन

| मॉडल             | GPU      | टोकन/सेकंड |
| ---------------- | -------- | ---------- |
| DeepSeek-1.3B    | RTX 3060 | \~120      |
| DeepSeek-6.7B    | RTX 3090 | \~70       |
| DeepSeek-6.7B    | RTX 4090 | \~100      |
| DeepSeek-33B     | A100     | \~40       |
| DeepSeek-V2-Lite | RTX 4090 | \~50       |

## तुलना

| मॉडल               | HumanEval | कोड गुणवत्ता |
| ------------------ | --------- | ------------ |
| DeepSeek-Coder-33B | 79.3%     | उत्कृष्ट     |
| CodeLlama-34B      | 53.7%     | अच्छा        |
| GPT-3.5-Turbo      | 72.6%     | अच्छा        |

## समस्या निवारण

### कोड पूर्णता काम नहीं कर रही है

* के साथ सही प्रॉम्प्ट प्रारूप सुनिश्चित करें `<|fim_prefix|>`, `<|fim_suffix|>`, `<|fim_middle|>`
* उपयुक्त सेट करें `max_new_tokens` कोड जनरेशन के लिए

### मॉडल बेकार आउटपुट दे रहा है

* जाँचें कि मॉडल पूरी तरह डाउनलोड हो चुका है
* सुनिश्चित करें कि CUDA का उपयोग हो रहा है: `model.device`
* कम तापमान आज़माएँ (कोड के लिए 0.2-0.5)

### धीमी इनफ़रेंस

* 5-10 गुना गति बढ़ाने के लिए vLLM का उपयोग करें
* सक्रिय करें `torch.compile()` transformers के लिए
* बड़े वेरिएंट के लिए क्वांटाइज़्ड मॉडल का उपयोग करें

### इम्पोर्ट त्रुटियाँ

* निर्भरताएँ स्थापित करें: `pip install transformers accelerate`
* PyTorch को 2.0+ पर अपडेट करें

## लागत का अनुमान

CLORE.AI मार्केटप्लेस की सामान्य दरें (2024 तक):

| GPU       | प्रति घंटा दर | प्रति दिन दर | 4-घंटे का सत्र |
| --------- | ------------- | ------------ | -------------- |
| RTX 3060  | \~$0.03       | \~$0.70      | \~$0.12        |
| RTX 3090  | \~$0.06       | \~$1.50      | \~$0.25        |
| RTX 4090  | \~$0.10       | \~$2.30      | \~$0.40        |
| A100 40GB | \~$0.17       | \~$4.00      | \~$0.70        |
| A100 80GB | \~$0.25       | \~$6.00      | \~$1.00        |

*मूल्य प्रदाता और मांग के अनुसार बदलते हैं। देखें* [*CLORE.AI मार्केटप्लेस*](https://clore.ai/marketplace) *वर्तमान दरों के लिए।*

**पैसे बचाएँ:**

* का उपयोग करें **स्पॉट** बाधित किए जा सकने वाले कार्य के लिए मार्केट — लगभग एक-तिहाई सर्वरों की स्पॉट कीमत ऑन-डिमांड से कम होती है (मध्य \~13% छूट), बाकी उससे मेल खाते हैं
* से भुगतान करें **CLORE** टोकन
* विभिन्न प्रदाताओं के बीच कीमतों की तुलना करें

## अगले चरण

* [DeepSeek-V3](/guides/guides_v2-hi/language-models/deepseek-v3.md) - नवीनतम DeepSeek प्रमुख मॉडल
* [CodeLlama](/guides/guides_v2-hi/language-models/codellama.md) - वैकल्पिक कोड मॉडल
* [Qwen2.5-Coder](/guides/guides_v2-hi/language-models/qwen25.md) - Alibaba का कोड मॉडल
* [vLLM](/guides/guides_v2-hi/language-models/vllm.md) - प्रोडक्शन परिनियोजन


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-hi/language-models/deepseek-coder.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
