Instructions to use Dorjzodovsuren/Mongolian_Llama3-v0.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Dorjzodovsuren/Mongolian_Llama3-v0.1 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/llama-3-8b-bnb-4bit") model = PeftModel.from_pretrained(base_model, "Dorjzodovsuren/Mongolian_Llama3-v0.1") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Dorjzodovsuren/Mongolian_Llama3-v0.1 with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf Dorjzodovsuren/Mongolian_Llama3-v0.1:Q4_K_M # Run inference directly in the terminal: llama cli -hf Dorjzodovsuren/Mongolian_Llama3-v0.1:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Dorjzodovsuren/Mongolian_Llama3-v0.1:Q4_K_M # Run inference directly in the terminal: llama cli -hf Dorjzodovsuren/Mongolian_Llama3-v0.1:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf Dorjzodovsuren/Mongolian_Llama3-v0.1:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf Dorjzodovsuren/Mongolian_Llama3-v0.1:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf Dorjzodovsuren/Mongolian_Llama3-v0.1:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf Dorjzodovsuren/Mongolian_Llama3-v0.1:Q4_K_M
Use Docker
docker model run hf.co/Dorjzodovsuren/Mongolian_Llama3-v0.1:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use Dorjzodovsuren/Mongolian_Llama3-v0.1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Dorjzodovsuren/Mongolian_Llama3-v0.1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Dorjzodovsuren/Mongolian_Llama3-v0.1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Dorjzodovsuren/Mongolian_Llama3-v0.1:Q4_K_M
- Ollama
How to use Dorjzodovsuren/Mongolian_Llama3-v0.1 with Ollama:
ollama run hf.co/Dorjzodovsuren/Mongolian_Llama3-v0.1:Q4_K_M
- Unsloth Studio
How to use Dorjzodovsuren/Mongolian_Llama3-v0.1 with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Dorjzodovsuren/Mongolian_Llama3-v0.1 to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Dorjzodovsuren/Mongolian_Llama3-v0.1 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Dorjzodovsuren/Mongolian_Llama3-v0.1 to start chatting
- Docker Model Runner
How to use Dorjzodovsuren/Mongolian_Llama3-v0.1 with Docker Model Runner:
docker model run hf.co/Dorjzodovsuren/Mongolian_Llama3-v0.1:Q4_K_M
- Lemonade
How to use Dorjzodovsuren/Mongolian_Llama3-v0.1 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Dorjzodovsuren/Mongolian_Llama3-v0.1:Q4_K_M
Run and chat with the model
lemonade run user.Mongolian_Llama3-v0.1-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Mongolian-Llama3
Model Description
Mongolian-Llama3 implementation in Chat UI
Mongolian-Llama3 is the first open source instruction-tuned language model for Mongolian & English users with various abilities such as roleplaying & tool-using built upon the quantized Meta-Llama-3-8B model.
Developed by: Dorjzodovsuren
License: Llama-3 License
Base Model: llama-3-8b-bnb-4bit
Model Size: 4.65B
Context length: 8K
Bias, Risks, and Limitations
To combat fake news, current strategies rely heavily on synthetic and translated data. However, these approaches have inherent biases, risks, and limitations:
Synthetic Data Bias: Algorithms may inadvertently perpetuate biases present in training data.
Translation Inaccuracy: Translations can distort meaning or lose context, leading to misinformation.
Cultural Nuances: Synthetic and translated data may miss cultural intricacies, risking amplification of stereotypes.
Algorithmic Limits: Effectiveness is constrained by algorithm capabilities and training data quality.
Dependency on Data: Accuracy hinges on quality and representativeness of training data.
Adversarial Attacks: Malicious actors can exploit vulnerabilities to manipulate content.
Different answer based on language: Answer might be a bit different based on language.
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. Due to hallucinations and pretraining datasets characteristics, some information might be misleading, and answer might be a bit different based on language.
Please ask in Mongolian if possible.
How to Get Started with the Model
Use the code below to get started with the model.
import torch
import gradio as gr
from threading import Thread
from peft import PeftModel, PeftConfig
from unsloth import FastLanguageModel
from transformers import TextStreamer
from transformers import AutoModelForCausalLM, AutoTokenizer, StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer
config = PeftConfig.from_pretrained("Dorjzodovsuren/Mongolian_llama3")
model = AutoModelForCausalLM.from_pretrained("unsloth/llama-3-8b-bnb-4bit", torch_dtype = torch.float16)
model = PeftModel.from_pretrained(model, "Dorjzodovsuren/Mongolian_llama3")
#load tokenizer
tokenizer = AutoTokenizer.from_pretrained("Dorjzodovsuren/Mn_llama3")
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
### Instruction:
{}
### Input:
{}
### Response:
{}"""
# Enable native 2x faster inference
FastLanguageModel.for_inference(model)
# Create a text streamer
text_streamer = TextStreamer(tokenizer, skip_prompt=False,skip_special_tokens=True)
# Get the device based on GPU availability
device = 'cuda' if torch.cuda.is_available() else 'cpu'
# Move model into device
model = model.to(device)
class StopOnTokens(StoppingCriteria):
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
stop_ids = [29, 0]
for stop_id in stop_ids:
if input_ids[0][-1] == stop_id:
return True
return False
# Current implementation does not support conversation based on previous conversation.
# Highly recommend to experiment on various hyper parameters to compare qualities.
def predict(message, history):
stop = StopOnTokens()
messages = alpaca_prompt.format(
message,
"",
"",
)
model_inputs = tokenizer([messages], return_tensors="pt").to(device)
streamer = TextIteratorStreamer(tokenizer, timeout=10., skip_prompt=True, skip_special_tokens=True)
generate_kwargs = dict(
model_inputs,
streamer=streamer,
max_new_tokens=1024,
top_p=0.95,
temperature=0.001,
repetition_penalty=1.1,
stopping_criteria=StoppingCriteriaList([stop])
)
t = Thread(target=model.generate, kwargs=generate_kwargs)
t.start()
partial_message = ""
for new_token in streamer:
if new_token != '<':
partial_message += new_token
yield partial_message
gr.ChatInterface(predict).launch(debug=True, share=True, show_api=True)
- Downloads last month
- 23
4-bit
