Instructions to use AI-Sweden-Models/gpt-sw3-356m-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-356m-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-356m-instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("AI-Sweden-Models/gpt-sw3-356m-instruct") model = AutoModelForCausalLM.from_pretrained("AI-Sweden-Models/gpt-sw3-356m-instruct") 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 Settings
- vLLM
How to use AI-Sweden-Models/gpt-sw3-356m-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-356m-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-356m-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/AI-Sweden-Models/gpt-sw3-356m-instruct
- SGLang
How to use AI-Sweden-Models/gpt-sw3-356m-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-356m-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-356m-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-356m-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-356m-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use AI-Sweden-Models/gpt-sw3-356m-instruct with Docker Model Runner:
docker model run hf.co/AI-Sweden-Models/gpt-sw3-356m-instruct
| END-USER LICENSE AGREEMENT (EULA) – RESEARCH USE ONLY | |
| IMPORTANT: READ CAREFULLY BEFORE USING THIS GPT-SW3. | |
| This End-User License Agreement ("Agreement") is a legal agreement between you (either an individual or a single legal entity, hereinafter "Licensee") and Lindholmen Science Park AB (hereinafter "Licensor") for the model GPT-SW3 accompanying this Agreement (hereinafter "GPT-SW3" or “Model”). | |
| By installing, copying, or otherwise using GPT-SW3, you agree to be bound by the terms of this Agreement. If you do not agree, do not use GPT-SW3. | |
| 1. GRANT OF LICENSE | |
| Subject to the terms of this Agreement, Licensor grants Licensee a limited, non-exclusive, non-transferable, and revocable license to use the GPT-SW3 solely for Internal Research Purposes. | |
| 2. RESTRICTIONS ON USE | |
| Licensee strictly agrees NOT to: | |
| * Commercialize: Use GPT-SW3 for any commercial purpose, including selling, leasing, or creating revenue-generating services. | |
| * Transfer: Sub-license, assign, rent, lease, lend, or transfer GPT-SW3 or this license to any third party. | |
| * Distribute: Publicly distribute, host, or make GPT-SW3 available on any network or repository. | |
| * Modify: Reverse engineer, decompile, or disassemble the GPT-SW3, except as permitted by applicable law. | |
| 3. ACADEMIC PUBLICATIONS | |
| Licensee is permitted to publish academic papers, articles, or presentations based on results obtained through the use of GPT-SW3, provided that: | |
| * Prior Notice: Licensee provides Licensor with a copy of the manuscript at least 30 days prior to submission for publication. | |
| * Confidentiality: No proprietary or confidential information of the Licensor is disclosed in the publication. | |
| 4. ATTRIBUTION AND CITATION | |
| Licensee agrees to acknowledge the use of the GPT-SW3 in any publication, presentation, or report resulting from its use. | |
| * Mandatory Citation: Licensee must explicitly cite the GPT-SW3 using the following format: "GPT-SW3, developed by AI Sweden, RISE and WASP." | |
| * Trademarks: Licensee shall not use Licensor’s logos, trademarks or explicit or implied endorsement without prior written consent, except for the purpose of the mandatory attribution stated above. | |
| 5. OWNERSHIP | |
| Licensor retains all right, title, and interest, including all intellectual property rights, in and to the GPT-SW3. No ownership rights are transferred to Licensee. | |
| 6. TERMINATION | |
| This Agreement is effective until terminated. Licensor may terminate this Agreement immediately without notice if Licensee fails to comply with any term. Upon termination, Licensee must cease all use and destroy all copies of GPT-SW3. | |
| 7. NO WARRANTY ("AS IS") | |
| THE GPT-SW3 IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. LICENSOR DISCLAIMS ALL WARRANTIES, INCLUDING MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
| 8. GOVERNING LAW | |
| This Agreement shall be governed by and construed in accordance with the laws of Sweden. |