Text Generation
Transformers
Safetensors
Swedish
Danish
Norwegian
llama
conversational
text-generation-inference
Instructions to use AI-Sweden-Models/Llama-3-8B-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AI-Sweden-Models/Llama-3-8B-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AI-Sweden-Models/Llama-3-8B-instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("AI-Sweden-Models/Llama-3-8B-instruct") model = AutoModelForCausalLM.from_pretrained("AI-Sweden-Models/Llama-3-8B-instruct", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use AI-Sweden-Models/Llama-3-8B-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AI-Sweden-Models/Llama-3-8B-instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AI-Sweden-Models/Llama-3-8B-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/AI-Sweden-Models/Llama-3-8B-instruct
- SGLang
How to use AI-Sweden-Models/Llama-3-8B-instruct 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 "AI-Sweden-Models/Llama-3-8B-instruct" \ --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": "AI-Sweden-Models/Llama-3-8B-instruct", "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 "AI-Sweden-Models/Llama-3-8B-instruct" \ --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": "AI-Sweden-Models/Llama-3-8B-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use AI-Sweden-Models/Llama-3-8B-instruct with Docker Model Runner:
docker model run hf.co/AI-Sweden-Models/Llama-3-8B-instruct
|
Download README.md from AI-Sweden-Models/Llama-3-8B-instruct: direct link, hf CLI and curl.
- Browser
- Download file 2.22 kB
-
https://huggingface.co/AI-Sweden-Models/Llama-3-8B-instruct/resolve/f90aeec60cfe2eb154338a693d5736389a8a243f/README.md
- Command line
-
hf download hf://AI-Sweden-Models/Llama-3-8B-instruct@f90aeec60cfe2eb154338a693d5736389a8a243f/README.md
-
curl -L -o README.md https://huggingface.co/AI-Sweden-Models/Llama-3-8B-instruct/resolve/f90aeec60cfe2eb154338a693d5736389a8a243f/README.md
2.22 kB
| language: | |
| - sv | |
| - da | |
| - 'no' | |
| license: llama3 | |
| base_model: AI-Sweden-Models/Llama-3-8B | |
| # Checkpoint 1 | |
| ## Training setup | |
| The training was perfomed on the [LUMI supercomputer](https://lumi-supercomputer.eu/) within the [DeployAI EU project](https://www.ai.se/en/project/deployai). | |
| Based of the base model [AI-Sweden-Models/Llama-3-8B](https://huggingface.co/AI-Sweden-Models/Llama-3-8B). | |
| ## Dataset | |
| A data recipe by: [42 Labs](https://huggingface.co/four-two-labs) | |
|  | |
| ## How to use | |
| ```python | |
| import transformers | |
| import torch | |
| model_id = "AI-Sweden-Models/Llama-3-8B-instruct" | |
| pipeline = transformers.pipeline( | |
| "text-generation", | |
| model=model_id, | |
| model_kwargs={"torch_dtype": torch.bfloat16}, | |
| device_map="auto", | |
| ) | |
| messages = [ | |
| {"role": "system", "content": "Du är en hjälpsam assistant som svarar klokt och vänligt."}, | |
| {"role": "user", "content": "Hur gör man pannkakor? Och vad behöver man handla? Undrar också vad 5+6 är.."}, | |
| ] | |
| terminators = [ | |
| pipeline.tokenizer.eos_token_id, | |
| pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>") | |
| ] | |
| outputs = pipeline( | |
| messages, | |
| max_new_tokens=256, | |
| eos_token_id=terminators, | |
| do_sample=True, | |
| temperature=0.6, | |
| top_p=0.9, | |
| ) | |
| print(outputs[0]["generated_text"][-1]) | |
| ``` | |
| ```python | |
| >>> "För att göra pannkakor behöver du följande ingredienser: | |
| - 1 kopp vetemjöl | |
| - 1 tesked bakpulver | |
| - 1/4 tesked salt | |
| - 1 kopp mjölk | |
| - 1 stort ägg | |
| - 2 matskedar smält smör eller olja | |
| För att börja, blanda vetemjölet, bakpulvret och saltet i en bunke. I en annan skål, vispa ihop mjölken, ägget och smöret eller oljan. | |
| Tillsätt de våta ingredienserna till de torra ingredienserna och blanda tills det är väl blandat. | |
| Låt smeten vila i cirka 10 minuter. | |
| För att göra pannkakorna, värm en non-stick-panna eller stekpanna över medelvärme. | |
| När den är varm, häll smeten på pannan och grädda tills kanterna börjar torka ut och toppen är fast. | |
| Vänd pannkakan med en stekspade och grädda den andra sidan tills den är gyllenbrun. | |
| Upprepa med resten av smeten. | |
| När det gäller 5+6 är svaret 11." | |
| ``` |