A collection of sampling methods for machine learning implemented on numpy.
Project description
Samplings
=========
A collection of sampling methods for machine learning implemented on numpy.
Author: Sander Wood
Provides
- Gamma sampling for controllable generation
- Local temperature sampling with weights
- Nucleus sampling (top-p sampling)
- Top-k sampling
- Random sampling
How to use
As you probably know, sampling means randomly picking the next token according
to its conditional probability distribution. In other words, given the same
probability distribution, you may get a different result each time. If you
want to get rid of this uncertainty, you can set seed to a fixed value.
By default, all the functions in samplings return the index of the next token.
However, you can ask them to return the modified probability distribution by set
return_probs as True. Then, you can make further manipulations based on this
probability distribution.
In addition to the probability distribution, most sampling methods require other parameters for modifying the probability distribution to achieve desired results. Please refer to the docstring of each function for details.
About gamma sampling
Gamma sampling is a method of tuning probabilities of target tokens to achieve controlling specific properties of the generated sequence. The basic assumption is that some attributes of sequences are closely related to the frequencies of some tokens. As long as the controllable attribute can be defined at the token level, prior knowledge can be directly brought into the sampling process, allowing arbitrary models to support customisable and controllable generation.
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 samplings-0.1.7.tar.gz.
File metadata
- Download URL: samplings-0.1.7.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
647f85b0bed5651b3717c05528e37f00b6c710e5679b641e129554eecc135d1c
|
|
| MD5 |
82961960ffcdba262dc0cf126181d9fa
|
|
| BLAKE2b-256 |
38cdd92f0ef943e7fd3208cf611fd06e945bea4ec37844616129da2a7bb20527
|
File details
Details for the file samplings-0.1.7-py3-none-any.whl.
File metadata
- Download URL: samplings-0.1.7-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e822913cf7498a5465027461a4b6986d19fb379c346492683236c77da98f8284
|
|
| MD5 |
69969f550580980bcf37e56b2b521421
|
|
| BLAKE2b-256 |
00c9fb82c0010e855425537f5ddbecb8b8cd47277a2ca52d9cec687426f2ab37
|