Instructions to use google/t5-3b-ssm-nq with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/t5-3b-ssm-nq with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="google/t5-3b-ssm-nq")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("google/t5-3b-ssm-nq") model = AutoModelForSeq2SeqLM.from_pretrained("google/t5-3b-ssm-nq", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use google/t5-3b-ssm-nq with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "google/t5-3b-ssm-nq" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/t5-3b-ssm-nq", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/google/t5-3b-ssm-nq
- SGLang
How to use google/t5-3b-ssm-nq 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 "google/t5-3b-ssm-nq" \ --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": "google/t5-3b-ssm-nq", "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 "google/t5-3b-ssm-nq" \ --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": "google/t5-3b-ssm-nq", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use google/t5-3b-ssm-nq with Docker Model Runner:
docker model run hf.co/google/t5-3b-ssm-nq
How to obtain 'score' outputs?
I wanted to get scores for each question I asked. When I followed the suggested method here https://huggingface.co/docs/transformers/v4.19.3/en/internal/generation_utils#transformers.generation_utils.GreedySearchEncoderDecoderOutput.scores
I get this error:
/usr/local/lib/python3.7/dist-packages/transformers/tokenization_utils_fast.py in _decode(self, token_ids, skip_special_tokens, clean_up_tokenization_spaces, **kwargs)
545 if isinstance(token_ids, int):
546 token_ids = [token_ids]
--> 547 text = self._tokenizer.decode(token_ids, skip_special_tokens=skip_special_tokens)
548
549 if clean_up_tokenization_spaces:
TypeError: Can't convert {'sequences': [[0, 25439, 1]], 'scores': [[[-84.4974365234375, -35.67204284667969, -44.91609573364258, -27.592676162719727, -38.73073196411133, -37.58429718017578, -32.03908920288086, -41.34073257446289, -37.01685333251953, -38.45159149169922, -37.466190338134766, -32.51167297363281, -35.718780517578125, ...
As I understand, scores should be an integer. But the decoder can't decode if it's not an integer value.
Any advice?
Hey @EnesDS , I think you simply need to replace token_ids simply by token_ids.sequencesin self._tokenizer.decode(...) - could you try this maybe?
Thank you, Patrick!
I tried this, but it still didn't work.
Here is the part where I made the change from the file transformers/token_utils_fast.py:
Here is the output after the change of the issue:
This is such a great abstractive QA model! To be able to obtain the confidence score would open a door to a great ways of usage.