Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

semantic_llm_short_ans_generator-0.1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file semantic_llm_short_ans_generator-0.1.1.tar.gz.

File metadata

File hashes

Hashes for semantic_llm_short_ans_generator-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f3380fd9ef15e5c6953abdd88e771c178e1303a9ba00fa4bea3d93768a5b2bc5
MD5 2a847316e68002259ac2b5e4ea7d41e4
BLAKE2b-256 10f36fb0282b7e6081b327738b242160d47a98dba7a0b783b346f0449ffdd0cb

See more details on using hashes here.

File details

Details for the file semantic_llm_short_ans_generator-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for semantic_llm_short_ans_generator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9b179ae93b30fd5df179988e6d0e74c399335771d5b93f9598976276e1d16037
MD5 7cd50db32bb013e3c8cb4d2d0b8051a1
BLAKE2b-256 5591e4f5b86c105cd222a866813bbf5f1443ea7f0ff16cbfdb70ddcebb409c6a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page