Instructions to use AI-Sweden-Models/gpt-sw3-1.3b-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AI-Sweden-Models/gpt-sw3-1.3b-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AI-Sweden-Models/gpt-sw3-1.3b-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/gpt-sw3-1.3b-instruct") model = AutoModelForCausalLM.from_pretrained("AI-Sweden-Models/gpt-sw3-1.3b-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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use AI-Sweden-Models/gpt-sw3-1.3b-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/gpt-sw3-1.3b-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/gpt-sw3-1.3b-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/AI-Sweden-Models/gpt-sw3-1.3b-instruct
- SGLang
How to use AI-Sweden-Models/gpt-sw3-1.3b-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/gpt-sw3-1.3b-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/gpt-sw3-1.3b-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/gpt-sw3-1.3b-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/gpt-sw3-1.3b-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use AI-Sweden-Models/gpt-sw3-1.3b-instruct with Docker Model Runner:
docker model run hf.co/AI-Sweden-Models/gpt-sw3-1.3b-instruct
translation
Hi team,
Would you recommend using this model for translating [ sv da nb ] to/from en ?
Cheers.
Yeah, try it, even the 6.7b models if you can.
Also check out: https://huggingface.co/AI-Sweden-Models/gpt-sw3-6.7b-v2-translator
Oh, if only my target environment had more memory, that translator fine-tuned model would be awesome, however up to 4B params would fit the bill. As I'm not native a speaker of sv / da / nb, I cannot tell whether the translations are good or somewhat hallucinated. Therefore, should I opt for a smaller translation fine-tuned models instead?
I have tried sv-en to/from using AI-Sweden (both GPT 1.3b and 6.7b v2 translator), X-ALMA and Helsinki-NLP. This model works good enough for translation but the 6.7b v2 Translator is way better in niche situations, but still NOT good on Industry specific language (None of the models are). X-LLama is similar to AI-Sweden/GPT sw3 6.7b v2 translator might be somewhat better but that expected from such a larger model.
The super lightweight one way translators from Helsinki-NLP are better than GPT 1.3b but worse compared to the bigger models. So if your limited in compute space (not storage due to needing 6 models from the Helsinki-NLP for to/from on 3 languages) then its a good choice. https://huggingface.co/Helsinki-NLP