> 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

{% 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)
   * यदि आवश्यक हो तो एनवायरनमेंट वेरिएबल जोड़ें
   * स्टार्टअप कमांड दर्ज करें
5. भुगतान चुनें: **CLORE**, **BTC**, या **USDT/USDC**
6. ऑर्डर बनाएं और डिप्लॉयमेंट का इंतज़ार करें

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

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

## DeepSeek Coder क्या है?

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

* अत्याधुनिक कोड जनरेशन
* 338 प्रोग्रामिंग भाषाएँ
* Fill-in-the-middle समर्थन
* Repository-स्तरीय समझ

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

| मॉडल                | पैरामीटर | 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.5.1-cuda12.4-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))
```

## Fill-in-the-Middle (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
)

# Fill-in-the-middle फॉर्मेट
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 में थ्रेड-सेफ़ LRU कैश लागू करें"}
]

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 websocket सर्वर लिखें"}
    ],
    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="Prompt", lines=5, placeholder="Describe the code you need..."),
        gr.Slider(0.1, 1.0, value=0.2, label="Temperature"),
        gr.Slider(256, 2048, value=1024, step=128, label="Max Tokens")
    ],
    outputs=gr.Code(language="python", label="Generated Code"),
    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-10x स्पीडअप के लिए 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) *वर्तमान दरों के लिए।*

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

* उपयोग करें **स्पॉट** लचीले वर्कलोड के लिए मार्केट (अक्सर 30-50% सस्ता)
* भुगतान करें **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.
