> 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/mistral-mixtral.md).

# Mistral & Mixtral

Clore.ai GPUs पर Mistral और Mixtral मॉडल चलाएँ

{% hint style="info" %}
**नए संस्करण उपलब्ध हैं!** देखें [**Mistral Small 3.1**](/guides/guides_v2-hi/language-models/mistral-small.md) (24B, Apache 2.0, RTX 4090 पर फिट होता है) और [**Mistral Large 3**](/guides/guides_v2-hi/language-models/mistral-large3.md) (675B MoE, अग्रणी-श्रेणी).
{% endhint %}

उच्च-गुणवत्ता वाले पाठ जनरेशन के लिए Mistral और Mixtral मॉडल चलाएँ।

{% 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>`

## मॉडल अवलोकन

| मॉडल                | पैरामीटर             | VRAM  | विशेषता                 |
| ------------------- | -------------------- | ----- | ----------------------- |
| Mistral-7B          | 7B                   | 8GB   | सामान्य प्रयोजन         |
| Mistral-7B-Instruct | 7B                   | 8GB   | चैट/निर्देश             |
| Mixtral-8x7B        | 46.7B (12.9B सक्रिय) | 24GB  | MoE, सर्वोत्तम गुणवत्ता |
| Mixtral-8x22B       | 141B                 | 80GB+ | सबसे बड़ा MoE           |

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

**Docker इमेज:**

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

**पोर्ट:**

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

**कमांड:**

```bash
pip install vllm && \\
python -m vllm.entrypoints.openai.api_server \
    --model mistralai/Mistral-7B-Instruct-v0.2 \\
    --port 8000
```

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

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

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

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

## इंस्टॉलेशन विकल्प

### Ollama का उपयोग करके (सबसे आसान)

```bash

# Ollama इंस्टॉल करें
curl -fsSL https://ollama.com/install.sh | sh

# Mistral चलाएँ
ollama run mistral

# Mixtral चलाएँ
ollama run mixtral
```

### vLLM का उपयोग करके

```bash
pip install vllm

# सर्वर शुरू करें
python -m vllm.entrypoints.openai.api_server \
    --model mistralai/Mistral-7B-Instruct-v0.2 \\
    --dtype float16
```

### Transformers का उपयोग

```bash
pip install transformers accelerate
```

## Transformers के साथ Mistral-7B

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

model_id = "mistralai/Mistral-7B-Instruct-v0.2"

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

messages = [
    {"role": "user", "content": "क्वांटम कंप्यूटिंग को सरल शब्दों में समझाइए"}
]

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

outputs = model.generate(
    inputs,
    max_new_tokens=500,
    do_sample=True,
    temperature=0.7,
    top_p=0.95
)

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

## Mixtral-8x7B

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

model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"

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

messages = [
    {"role": "user", "content": "फाइबोनैचि संख्याएँ गणना करने के लिए एक Python फ़ंक्शन लिखें"}
]

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

outputs = model.generate(
    inputs,
    max_new_tokens=1000,
    do_sample=True,
    temperature=0.7
)

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

## क्वांटाइज़्ड मॉडल (कम VRAM)

### 4-बिट क्वांटाइज़ेशन

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

quantization_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_compute_dtype=torch.float16,
    bnb_4bit_quant_type="nf4"
)

model = AutoModelForCausalLM.from_pretrained(
    "mistralai/Mixtral-8x7B-Instruct-v0.1",
    quantization_config=quantization_config,
    device_map="auto"
)
```

### llama.cpp के साथ GGUF

```bash

# GGUF मॉडल डाउनलोड करें
wget https://huggingface.co/bartowski/Mistral-7B-Instruct-v0.3-GGUF/resolve/main/Mistral-7B-Instruct-v0.3-Q4_K_M.gguf

# llama.cpp के साथ चलाएँ
./main -m Mistral-7B-Instruct-v0.3-Q4_K_M.gguf \
    -p "मशीन लर्निंग समझाइए" \
    -n 500
```

## vLLM सर्वर (उत्पादन)

```bash
python -m vllm.entrypoints.openai.api_server \
    --model mistralai/Mistral-7B-Instruct-v0.2 \\
    --dtype float16 \\
    --max-model-len 8192 \
    --gpu-memory-utilization 0.9
```

### OpenAI-संगत API

```python
from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:8000/v1",
    api_key="not-needed"
)

response = client.chat.completions.create(
    model="mistralai/Mistral-7B-Instruct-v0.2",
    messages=[
        {"role": "user", "content": "फ्रांस की राजधानी क्या है?"}
    ],
    temperature=0.7,
    max_tokens=500
)

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

## स्ट्रीमिंग

```python
from openai import OpenAI

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

stream = client.chat.completions.create(
    model="mistralai/Mistral-7B-Instruct-v0.2",
    messages=[{"role": "user", "content": "एक रोबोट के बारे में एक कहानी लिखें"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
```

## फ़ंक्शन कॉलिंग

Mistral फ़ंक्शन कॉलिंग का समर्थन करता है:

```python
from openai import OpenAI

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

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "किसी स्थान के लिए मौसम प्राप्त करें",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {"type": "string"},
                    "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
                },
                "required": ["location"]
            }
        }
    }
]

response = client.chat.completions.create(
    model="mistralai/Mistral-7B-Instruct-v0.2",
    messages=[{"role": "user", "content": "पेरिस में मौसम कैसा है?"}],
    tools=tools
)

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

## Gradio इंटरफ़ेस

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

model_id = "mistralai/Mistral-7B-Instruct-v0.2"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.float16,
    device_map="auto"
)

def chat(message, history, temperature, max_tokens):
    messages = []
    for h in history:
        messages.append({"role": "user", "content": h[0]})
        messages.append({"role": "assistant", "content": h[1]})
    messages.append({"role": "user", "content": message})

    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
    )

    response = tokenizer.decode(outputs[0], skip_special_tokens=True)
    # सहायक का उत्तर निकालें
    return response.split("[/INST]")[-1].strip()

demo = gr.ChatInterface(
    fn=chat,
    additional_inputs=[
        gr.Slider(0.1, 2.0, value=0.7, label="तापमान"),
        gr.Slider(100, 2000, value=500, step=100, label="अधिकतम टोकन")
    ],
    title="Mistral-7B चैट"
)

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

## प्रदर्शन तुलना

### थ्रूपुट (टोकन/सेकंड)

| मॉडल              | RTX 3060 | RTX 3090 | RTX 4090 | A100 40GB |
| ----------------- | -------- | -------- | -------- | --------- |
| Mistral-7B FP16   | 45       | 80       | 120      | 150       |
| Mistral-7B Q4     | 70       | 110      | 160      | 200       |
| Mixtral-8x7B FP16 | -        | -        | 30       | 60        |
| Mixtral-8x7B Q4   | -        | 25       | 50       | 80        |
| Mixtral-8x22B Q4  | -        | -        | -        | 25        |

### पहले टोकन तक का समय (TTFT)

| मॉडल          | RTX 3090 | RTX 4090 | A100  |
| ------------- | -------- | -------- | ----- |
| Mistral-7B    | 80ms     | 50ms     | 35ms  |
| Mixtral-8x7B  | -        | 150ms    | 90ms  |
| Mixtral-8x22B | -        | -        | 200ms |

### संदर्भ लंबाई बनाम VRAM (Mistral-7B)

| संदर्भ | FP16 | Q8   | Q4   |
| ------ | ---- | ---- | ---- |
| 4K     | 15GB | 9GB  | 5GB  |
| 8K     | 18GB | 11GB | 7GB  |
| 16K    | 24GB | 15GB | 9GB  |
| 32K    | 36GB | 22GB | 14GB |

## VRAM आवश्यकताएँ

| मॉडल          | FP16  | 8-बिट | 4-बिट |
| ------------- | ----- | ----- | ----- |
| Mistral-7B    | 14GB  | 8GB   | 5GB   |
| Mixtral-8x7B  | 90GB  | 45GB  | 24GB  |
| Mixtral-8x22B | 180GB | 90GB  | 48GB  |

## उपयोग के मामले

### कोड जनरेशन

```python
prompt = """
एक REST API क्लाइंट के लिए Python क्लास लिखें, जिसमें:
- प्रमाणीकरण प्रबंधन
- पुनः प्रयास तर्क
- त्रुटि प्रबंधन
"""
```

### डेटा विश्लेषण

```python
prompt = """
इस डेटा का विश्लेषण करें और अंतर्दृष्टि प्रदान करें:
बिक्री Q1: $100K
बिक्री Q2: $150K
बिक्री Q3: $120K
बिक्री Q4: $200K
"""
```

### रचनात्मक लेखन

```python
prompt = """
एक AI के बारे में एक छोटी कहानी लिखें जो आत्म-जागरूक हो जाती है,
इसाक असिमोव की शैली में।
"""
```

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

### मेमोरी समाप्त

* 4-बिट क्वांटाइज़ेशन का उपयोग करें
* Mixtral के बजाय Mistral-7B का उपयोग करें
* max\_model\_len कम करें

### धीमी जनरेशन

* उत्पादन के लिए vLLM का उपयोग करें
* फ्लैश अटेंशन सक्षम करें
* मल्टी-GPU के लिए टेन्सर पैरललिज़्म का उपयोग करें

### खराब आउटपुट गुणवत्ता

* तापमान समायोजित करें (0.1-0.9)
* इंस्ट्रक्ट संस्करण का उपयोग करें
* बेहतर सिस्टम प्रॉम्प्ट्स

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

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** टोकन
* विभिन्न प्रदाताओं के बीच कीमतों की तुलना करें

## अगले चरण

* [vLLM](/guides/guides_v2-hi/language-models/vllm.md) - उत्पादन सर्विंग
* [Ollama](/guides/guides_v2-hi/language-models/ollama.md) - आसान परिनियोजन
* [DeepSeek-V3](/guides/guides_v2-hi/language-models/deepseek-v3.md) - सर्वोत्तम तर्क मॉडल
* [Qwen2.5](/guides/guides_v2-hi/language-models/qwen25.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/mistral-mixtral.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.
