mchl-labs/stambecco_data_it
Viewer • Updated • 51.7k • 38 • 4
How to use walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForMultimodalLM
tokenizer = AutoTokenizer.from_pretrained("walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita")
model = AutoModelForMultimodalLM.from_pretrained("walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita")
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]:]))How to use walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita
How to use walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita" \
--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": "walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita" \
--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": "walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita with Unsloth Studio:
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 walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita to start chatting
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 walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita",
max_seq_length=2048,
)How to use walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita with Docker Model Runner:
docker model run hf.co/walid-iguider/Phi-3-mini-4k-instruct-bnb-4bit-Ita
For a detailed comparison of model performance, check out the Leaderboard for Italian Language Models.
Here's a breakdown of the performance metrics:
| Metric | hellaswag_it acc_norm | arc_it acc_norm | m_mmlu_it 5-shot acc | Average |
|---|---|---|---|---|
| Accuracy Normalized | 0.5841 | 0.4414 | 0.5389 | 0.5214 |
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
tokenizer = AutoTokenizer.from_pretrained("FairMind/Phi-3-mini-4k-instruct-bnb-4bit-Ita")
model = AutoModelForCausalLM.from_pretrained("FairMind/Phi-3-mini-4k-instruct-bnb-4bit-Ita")
model.to(device)
generation_config = GenerationConfig(
penalty_alpha=0.6, # The values balance the model confidence and the degeneration penalty in contrastive search decoding.
do_sample = True, # Whether or not to use sampling ; use greedy decoding otherwise.
top_k=5, # The number of highest probability vocabulary tokens to keep for top-k-filtering.
temperature=0.001, # The value used to modulate the next token probabilities.
repetition_penalty=1.7, # The parameter for repetition penalty. 1.0 means no penalty.
max_new_tokens = 64, # The maximum numbers of tokens to generate, ignoring the number of tokens in the prompt.
eos_token_id=tokenizer.eos_token_id, # The id of the *end-of-sequence* token.
pad_token_id=tokenizer.eos_token_id, # The id of the *padding* token.
)
def generate_answer(question):
messages = [
{"role": "user", "content": question},
]
model_inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(device)
outputs = model.generate(model_inputs, generation_config=generation_config)
result = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
return result
question = """Quale è la torre più famosa di Parigi?"""
answer = generate_answer(question)
print(answer)
This model was trained 2x faster with Unsloth and Huggingface's TRL library.
Base model
unsloth/Phi-3-mini-4k-instruct-bnb-4bit