Instructions to use typhoon-ai/Llama-SEA-LION-TH-audio-preview with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use typhoon-ai/Llama-SEA-LION-TH-audio-preview with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="typhoon-ai/Llama-SEA-LION-TH-audio-preview", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("typhoon-ai/Llama-SEA-LION-TH-audio-preview", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use typhoon-ai/Llama-SEA-LION-TH-audio-preview with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "typhoon-ai/Llama-SEA-LION-TH-audio-preview" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "typhoon-ai/Llama-SEA-LION-TH-audio-preview", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/typhoon-ai/Llama-SEA-LION-TH-audio-preview
- SGLang
How to use typhoon-ai/Llama-SEA-LION-TH-audio-preview 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 "typhoon-ai/Llama-SEA-LION-TH-audio-preview" \ --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": "typhoon-ai/Llama-SEA-LION-TH-audio-preview", "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 "typhoon-ai/Llama-SEA-LION-TH-audio-preview" \ --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": "typhoon-ai/Llama-SEA-LION-TH-audio-preview", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use typhoon-ai/Llama-SEA-LION-TH-audio-preview with Docker Model Runner:
docker model run hf.co/typhoon-ai/Llama-SEA-LION-TH-audio-preview
Llama-SEA-LION-TH-audio-preview
Llama-SEA-LION-TH-audio-preview is a ๐น๐ญ Thai audio-language model designed to natively support both text and audio inputs, with text output. This is a research preview, the result of a collaborative effort between SCB10X and AI Singapore. The model is built on top of aisingapore/Llama-SEA-LION-v3-8B-IT, a powerful instruction-tuned language model for Southeast Asian languages.
Model Description
- Model type: The LLM is based on Llama-SEA-LION-v3-8B-IT, and the audio encoder is based on Whisper's encoder and BEATs.
- Requirement: transformers 4.45.0
- Primary Language(s): Thai ๐น๐ญ and English ๐ฌ๐ง
- License: Llama 3 Community License
Usage Example
from transformers import AutoModel
import soundfile as sf
import librosa
# Initialize from the trained model
model = AutoModel.from_pretrained(
"",
torch_dtype=torch.float16,
trust_remote_code=True
)
model.to("cuda")
model.eval()
# read a wav file (it needs to be in 16 kHz and clipped to 30 seconds)
audio, sr = sf.read("path_to_your_audio.wav")
if len(audio.shape) == 2:
audio = audio[:, 0]
if len(audio) > 30 * sr:
audio = audio[: 30 * sr]
if sr != 16000:
audio = librosa.resample(audio, orig_sr=sr, target_sr=16000, res_type="fft")
# Run generation
prompt_pattern="<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n<Speech><SpeechHere></Speech> {}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
response = model.generate(
audio=audio,
prompt="transcribe this audio",
prompt_pattern=prompt_pattern,
do_sample=False,
max_new_tokens=512,
repetition_penalty=1.1,
num_beams=1,
# temperature=0.4,
# top_p=0.9,
)
print(response)
Generation Parameters:
- audio -- audio input, e.g., using
soundfile.readorlibrosa.resampleto read a wav file like the example above - prompt (
str) -- Text input to the model - prompt_pattern (
str) -- Chat template that is augmented with special tokens, and it must be set the same as one during training - max_new_tokens (
int, optional, defaults to 1024) - num_beams (
int, optional, defaults to 4) - do_sample (
bool, optional, defaults to True) - top_p (
float, optional, defaults to 0.9) - repetition_penalty (
float, optional, defaults to 1.0), - length_penalty (
float, optional, defaults to 1.0), - temperature (
float, optional, defaults to 1.0),
This is also model.generate_stream() for streaming generation. Please refer to modeling_typhoonaudio.py for this function.
Intended Uses & Limitations
This model is experimental and may not always follow human instructions accurately, making it prone to generating hallucinations. Additionally, the model lacks moderation mechanisms and may produce harmful or inappropriate responses. Developers should carefully assess potential risks based on their specific applications.
Acknowledgements
This work builds upon the foundations laid by scb10x/llama-3-typhoon-v1.5-8b-audio-preview and its accompanying technical report, which we closely followed.
- Downloads last month
- 14