> 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

{% hint style="info" %}
**नवीनतम संस्करण उपलब्ध हैं!** देखें [**मिस्ट्रल स्मॉल 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)
   * यदि आवश्यक हो तो एनवायरनमेंट वेरिएबल जोड़ें
   * स्टार्टअप कमांड दर्ज करें
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.5.1-cuda12.4-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"
)
```

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

```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="Temperature"),
        gr.Slider(100, 2000, value=500, step=100, label="Max Tokens")
    ],
    title="Mistral-7B Chat"
)

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) *वर्तमान दरों के लिए।*

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

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