Instructions to use google/DiarizationLM-13b-Fisher-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/DiarizationLM-13b-Fisher-v1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="google/DiarizationLM-13b-Fisher-v1")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("google/DiarizationLM-13b-Fisher-v1") model = AutoModelForCausalLM.from_pretrained("google/DiarizationLM-13b-Fisher-v1") - llama-cpp-python
How to use google/DiarizationLM-13b-Fisher-v1 with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="google/DiarizationLM-13b-Fisher-v1", filename="q4_k_m.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use google/DiarizationLM-13b-Fisher-v1 with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf google/DiarizationLM-13b-Fisher-v1:Q4_K_M # Run inference directly in the terminal: llama-cli -hf google/DiarizationLM-13b-Fisher-v1:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf google/DiarizationLM-13b-Fisher-v1:Q4_K_M # Run inference directly in the terminal: llama-cli -hf google/DiarizationLM-13b-Fisher-v1:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf google/DiarizationLM-13b-Fisher-v1:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf google/DiarizationLM-13b-Fisher-v1:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf google/DiarizationLM-13b-Fisher-v1:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf google/DiarizationLM-13b-Fisher-v1:Q4_K_M
Use Docker
docker model run hf.co/google/DiarizationLM-13b-Fisher-v1:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use google/DiarizationLM-13b-Fisher-v1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "google/DiarizationLM-13b-Fisher-v1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/DiarizationLM-13b-Fisher-v1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/google/DiarizationLM-13b-Fisher-v1:Q4_K_M
- SGLang
How to use google/DiarizationLM-13b-Fisher-v1 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/DiarizationLM-13b-Fisher-v1" \ --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/DiarizationLM-13b-Fisher-v1", "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/DiarizationLM-13b-Fisher-v1" \ --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/DiarizationLM-13b-Fisher-v1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Ollama
How to use google/DiarizationLM-13b-Fisher-v1 with Ollama:
ollama run hf.co/google/DiarizationLM-13b-Fisher-v1:Q4_K_M
- Unsloth Studio new
How to use google/DiarizationLM-13b-Fisher-v1 with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for google/DiarizationLM-13b-Fisher-v1 to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for google/DiarizationLM-13b-Fisher-v1 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for google/DiarizationLM-13b-Fisher-v1 to start chatting
- Docker Model Runner
How to use google/DiarizationLM-13b-Fisher-v1 with Docker Model Runner:
docker model run hf.co/google/DiarizationLM-13b-Fisher-v1:Q4_K_M
- Lemonade
How to use google/DiarizationLM-13b-Fisher-v1 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull google/DiarizationLM-13b-Fisher-v1:Q4_K_M
Run and chat with the model
lemonade run user.DiarizationLM-13b-Fisher-v1-Q4_K_M
List all available models
lemonade list
This is not an officially supported Google product.
Overview
Note: This model is outdated. Please use google/DiarizationLM-8b-Fisher-v2 instead.
DiarizationLM model finetuned on the training subset of the Fisher corpus.
- Foundation model: unsloth/llama-2-13b-bnb-4bit
- Finetuning scripts: https://github.com/google/speaker-id/tree/master/DiarizationLM/unsloth
Training config
This model is finetuned on the training subset of the Fisher corpus, using a LoRA adapter of rank 256. The total number of training parameters is 1,001,390,080. With a batch size of 16, this model has been trained for 12000 steps, which is ~4 epochs of the training data.
We use the mixed flavor during our training, meaning we combine data from hyp2ora and deg2ref flavors. After the prompt builder, we have a total of 48,142 prompt-completion pairs in our training set.
The finetuning took more than 3 days on a Google Cloud VM instance that has one NVIDIA A100 GPU with 80GB memory.
The maximal length of the prompt to this model is 6000 characters, including the " --> " suffix. The maximal sequence length is 4096 tokens.
Metrics
Performance on the Fisher testing set:
| System | WER (%) | WDER (%) | cpWER (%) |
|---|---|---|---|
| USM + turn-to-diarize baseline | 15.48 | 5.32 | 21.19 |
| + This model | - | 3.65 | 18.92 |
Usage
First, you need to install two packages:
pip install transformers diarizationlm
On a machine with GPU and CUDA, you can use the model by running the following script:
from transformers import LlamaForCausalLM, LlamaTokenizer
from diarizationlm import utils
HYPOTHESIS = """<speaker:1> Hello, how are you doing <speaker:2> today? I am doing well. What about <speaker:1> you? I'm doing well, too. Thank you."""
print("Loading model...")
tokenizer = LlamaTokenizer.from_pretrained("google/DiarizationLM-13b-Fisher-v1", device_map="cuda")
model = LlamaForCausalLM.from_pretrained("google/DiarizationLM-13b-Fisher-v1", device_map="cuda")
print("Tokenizing input...")
inputs = tokenizer([HYPOTHESIS + " --> "], return_tensors = "pt").to("cuda")
print("Generating completion...")
outputs = model.generate(**inputs,
max_new_tokens = inputs.input_ids.shape[1] * 1.2,
use_cache = False)
print("Decoding completion...")
completion = tokenizer.batch_decode(outputs[:, inputs.input_ids.shape[1]:],
skip_special_tokens = True)[0]
print("Transferring completion to hypothesis text...")
transferred_completion = utils.transfer_llm_completion(completion, HYPOTHESIS)
print("========================================")
print("Hypothesis:", HYPOTHESIS)
print("========================================")
print("Completion:", completion)
print("========================================")
print("Transferred completion:", transferred_completion)
print("========================================")
The output will look like below:
Loading model...
Loading checkpoint shards: 100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 6/6 [00:17<00:00, 2.84s/it]
Tokenizing input...
Generating completion...
Decoding completion...
Transferring completion to hypothesis text...
========================================
Hypothesis: <speaker:1> Hello, how are you doing <speaker:2> today? I am doing well. What about <speaker:1> you? I'm doing well, too. Thank you.
========================================
Completion: 19:27 <speaker:1> hello, how are you doing today? <speaker:2> i am doing well. What about you? <speaker:1> i'm doing well, too. thank you. <speaker:2> my name
========================================
Transferred completion: <speaker:1> Hello, how are you doing today? <speaker:2> I am doing well. What about you? <speaker:1> I'm doing well, too. Thank you.
Citation
Our paper is cited as:
@article{wang2024diarizationlm,
title={{DiarizationLM: Speaker Diarization Post-Processing with Large Language Models}},
author={Quan Wang and Yiling Huang and Guanlong Zhao and Evan Clark and Wei Xia and Hank Liao},
journal={arXiv preprint arXiv:2401.03506},
year={2024}
}
- Downloads last month
- 189