Sample responses and log-probabilities from HuggingFace causal LMs
Project description
LLM Sampler
A utility library for sampling responses and extracting log-probabilities from HuggingFace causal language models.
Installation
pip install llm-sampler
Features
- Response Sampling: Sample diverse responses from causal language models
- Log-Probability Extraction: Extract log-probabilities for generated tokens
- HuggingFace Integration: Works seamlessly with HuggingFace transformers
- Batch Processing: Efficient batch sampling and probability computation
Usage
from llm_sampler import LMSampler
sampler = LMSampler("gpt2")
responses, log_probs = sampler.sample(prompt, num_samples=5)
Dependencies
- torch >= 2.0
- transformers >= 4.31
- sentencepiece
License
See LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file semantic_llm_short_ans_generator-0.1.1.tar.gz.
File metadata
- Download URL: semantic_llm_short_ans_generator-0.1.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3380fd9ef15e5c6953abdd88e771c178e1303a9ba00fa4bea3d93768a5b2bc5
|
|
| MD5 |
2a847316e68002259ac2b5e4ea7d41e4
|
|
| BLAKE2b-256 |
10f36fb0282b7e6081b327738b242160d47a98dba7a0b783b346f0449ffdd0cb
|
File details
Details for the file semantic_llm_short_ans_generator-0.1.1-py3-none-any.whl.
File metadata
- Download URL: semantic_llm_short_ans_generator-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b179ae93b30fd5df179988e6d0e74c399335771d5b93f9598976276e1d16037
|
|
| MD5 |
7cd50db32bb013e3c8cb4d2d0b8051a1
|
|
| BLAKE2b-256 |
5591e4f5b86c105cd222a866813bbf5f1443ea7f0ff16cbfdb70ddcebb409c6a
|