Instructions to use jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-beta with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-beta with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-beta", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-beta", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-beta", trust_remote_code=True) 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
- vLLM
How to use jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-beta with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-beta" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-beta", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-beta
- SGLang
How to use jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-beta 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 "jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-beta" \ --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": "jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-beta", "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 "jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-beta" \ --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": "jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-beta", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-beta with Docker Model Runner:
docker model run hf.co/jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-beta
Model Card for Model ID
French-Alpaca based on microsoft/Phi-3-mini-128k-instruct
128k is the context length (in tokens)
Model Description
fine-tuned from the original French-Alpaca-dataset entirely generated with OpenAI GPT-3.5-turbo.
French-Alpaca is a general model and can itself be finetuned to be specialized for specific use cases.
The fine-tuning method is inspired from https://crfm.stanford.edu/2023/03/13/alpaca.html
128k version not yet supported by llama.cpp
4k GGUF version available : https://huggingface.co/jpacifico/French-Alpaca-Phi-3-GGUF
Usage
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
torch.random.manual_seed(0)
model = AutoModelForCausalLM.from_pretrained(
"microsoft/Phi-3-mini-4k-instruct",
device_map="cuda",
torch_dtype="auto",
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained("jpacifico/French-Alpaca-Phi-3-mini-128k-instruct-v1.0")
messages = [
{"role": "system", "content": "Vous êtes un assistant numérique serviable. Veuillez fournir des informations sûres, éthiques et précises à l'utilisateur."},
{"role": "user", "content": "Pouvez-vous fournir des façons de manger des combinaisons de bananes et de fruits du dragon ?"},
{"role": "assistant", "content": "Bien sûr ! Voici quelques façons de manger des bananes et des fruits du dragon ensemble : 1. Smoothie à la banane et au fruit du dragon : mixez des bananes et des fruits du dragon avec un peu de lait et de miel. 2. Salade de banane et de fruit du dragon : mélangez des bananes tranchées et des fruits du dragon avec un peu de jus de citron et de miel."},
{"role": "user", "content": "Et pour résoudre une équation 2x + 3 = 7 ?"},
]
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
)
generation_args = {
"max_new_tokens": 500,
"return_full_text": False,
"temperature": 0.0,
"do_sample": False,
}
output = pipe(messages, **generation_args)
print(output[0]['generated_text'])
Limitations
The French-Alpaca model is a quick demonstration that a 3B base model can be easily fine-tuned to specialize in a particular language. It does not have any moderation mechanisms.
- Developed by: Jonathan Pacifico, 2024
- Model type: LLM
- Language(s) (NLP): French
- License: MIT
- Downloads last month
- 19
