Text Generation
Transformers
Safetensors
mixtral
conversational
text-generation-inference
4-bit precision
awq
Instructions to use lightblue/Karasu-Mixtral-8x22B-v0.1-AWQ with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lightblue/Karasu-Mixtral-8x22B-v0.1-AWQ with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="lightblue/Karasu-Mixtral-8x22B-v0.1-AWQ") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("lightblue/Karasu-Mixtral-8x22B-v0.1-AWQ") model = AutoModelForMultimodalLM.from_pretrained("lightblue/Karasu-Mixtral-8x22B-v0.1-AWQ") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use lightblue/Karasu-Mixtral-8x22B-v0.1-AWQ with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lightblue/Karasu-Mixtral-8x22B-v0.1-AWQ" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lightblue/Karasu-Mixtral-8x22B-v0.1-AWQ", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/lightblue/Karasu-Mixtral-8x22B-v0.1-AWQ
- SGLang
How to use lightblue/Karasu-Mixtral-8x22B-v0.1-AWQ with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "lightblue/Karasu-Mixtral-8x22B-v0.1-AWQ" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lightblue/Karasu-Mixtral-8x22B-v0.1-AWQ", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "lightblue/Karasu-Mixtral-8x22B-v0.1-AWQ" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lightblue/Karasu-Mixtral-8x22B-v0.1-AWQ", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use lightblue/Karasu-Mixtral-8x22B-v0.1-AWQ with Docker Model Runner:
docker model run hf.co/lightblue/Karasu-Mixtral-8x22B-v0.1-AWQ
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
4bit AWQ version of the lightblue/Karasu-Mixtral-8x22B-v0.1 model.
Quantized using the following code:
from awq import AutoAWQForCausalLM
import pandas as pd
from transformers import AutoTokenizer
from tqdm.auto import tqdm
pretrained_model_dir = '/workspace/llm_training/axolotl/mixtral_8x22B_training/merged_model_multiling'
quantized_model_dir = '/workspace/llm_training/axolotl/mixtral_8x22B_training/merged_model_multiling-awq'
# The samne dataset as in lightblue/gpt4_conversations_multilingual
df = pd.read_json(
"/workspace/llm_training/axolotl/mixtral_8x22B_training/sharegpt4_multilingual.json",
lines=True)
role_map = {
"human": "user",
"gpt": "assistant",
}
df["messages"] = df.conversations.apply(lambda x: [{"role": role_map[y["from"]], "content": y["value"]} for y in x])
tokenizer = AutoTokenizer.from_pretrained(pretrained_model_dir, use_fast=True)
examples = [
tokenizer.apply_chat_template(
x, tokenize=False, add_generation_prompt=False
) for x in tqdm(df["messages"])
]
model_path = '/workspace/llm_training/axolotl/mixtral_8x22B_training/merged_model_multiling'
quant_path = '/workspace/llm_training/axolotl/mixtral_8x22B_training/merged_model_multiling-awq'
quant_config = { "zero_point": True, "q_group_size": 128, "w_bit": 4, "version": "GEMM" }
# Load model
model = AutoAWQForCausalLM.from_pretrained(model_path)
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
# Quantize
model.quantize(tokenizer, quant_config=quant_config, calib_data=examples)
# Save quantized model
model.save_quantized(quant_path)
tokenizer.save_pretrained(quant_path)
- Downloads last month
- 3