Instructions to use ltg/nort5-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ltg/nort5-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ltg/nort5-base", trust_remote_code=True)# Load model directly from transformers import AutoModelForSeq2SeqLM model = AutoModelForSeq2SeqLM.from_pretrained("ltg/nort5-base", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use ltg/nort5-base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ltg/nort5-base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ltg/nort5-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ltg/nort5-base
- SGLang
How to use ltg/nort5-base 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 "ltg/nort5-base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ltg/nort5-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "ltg/nort5-base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ltg/nort5-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ltg/nort5-base with Docker Model Runner:
docker model run hf.co/ltg/nort5-base
Can't get model to run with example on model card
I'm having some issues getting the model to run. The example usage does not work. Aside from the import error (from modeling_nor*bert* not from modeling_nor*t5*) there seems to be some wrong with the script to interface with hugging face standards.
I get the message AttributeError: 'function' has no attribute 'forward'. I believe this is because the get_encoder function in NorT5Model returns the get_encoder_output function, not an object. I've tried to write an encoder wrapper around the Encoder class which implements the get_encoder_output function as its forward function, but then I get an issue with the shape of input_shape, so maybe this is the wrong way around. Any help?
Here is the code I'm running, copied from the example.
import torch
from transformers import AutoTokenizer
from modeling_nort5 import NorT5ForConditionalGeneration
tokenizer = AutoTokenizer.from_pretrained("path/to/model")
model = NorT5ForConditionalGeneration.from_pretrained("path/to/model")
#LANGUAGE MODELING
sentence = "Brukseksempel: Elektrisk oppvarming. Definisjonen på ordet oppvarming er[MASK_0]."
input_tensor = tokenizer(sentence, return_tensors="pt").input_ids
output_tensor = model.generate(input_tensor, decoder_start_token_id=7, eos_token_id=8)
print(tokenizer.decode(output_tensor.squeeze(), skip_special_tokens=True))
# should output: å varme opp
Hei, I have tried the same thing and I'm getting the same error message.AttributeError: 'function' object has no attribute 'forward`
Hi, thanks a lot for raising this issue! There was indeed a compatibility problem with the newest huggingface version, it should be fixed now :)