This repository implements the DeepCONF (Deep Confidence-based Early Stopping) generation strategy for Hugging Face Transformers models, following the
Deep Think with Confidence
approach from the paper
Deep Think with Confidence
.
Overview
DeepCONF monitors the confidence of generated tokens and stops generation when confidence falls below a threshold.
Parameters
enable_conf
(bool): Whether to enable the DeepCONF strategy. Defaults to
False
.
window_size
(int): Size of the sliding window for confidence calculation. Defaults to
2048
.
threshold
(float): Confidence threshold for early stopping. Defaults to
17.0
.
output_confidences
(bool): If
True
and
return_dict_in_generate=True
, returns a per-step confidence tensor alongside generated sequences for debugging/visualization.
Usage
To use this custom generation strategy, you can pass it directly to the
generate
method:
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("your-model")
tokenizer = AutoTokenizer.from_pretrained("your-model")
inputs = tokenizer("Hello, world!", return_tensors="pt")
# Generate with DeepCONF (Hub repo)
outputs = model.generate(
**inputs,
enable_conf=True,
window_size=2048,
threshold=17.0,
output_confidences=True, # request confidences
return_dict_in_generate=True, # required to get tensors
max_new_tokens=100,
custom_generate="kashif/DeepConf", # Hugging Face Hub repo
trust_remote_code=True
)
Requirements
PyTorch >= 1.13.0
Transformers >= 4.35.0
Runs of kashif DeepConf on huggingface.co
19
Total runs
0
24-hour runs
1
3-day runs
3
7-day runs
4
30-day runs
More Information About DeepConf huggingface.co Model
DeepConf huggingface.co is an AI model on huggingface.co that provides DeepConf's model effect (), which can be used instantly with this kashif DeepConf model. huggingface.co supports a free trial of the DeepConf model, and also provides paid use of the DeepConf. Support call DeepConf model through api, including Node.js, Python, http.
DeepConf huggingface.co is an online trial and call api platform, which integrates DeepConf's modeling effects, including api services, and provides a free online trial of DeepConf, you can try DeepConf online for free by clicking the link below.
kashif DeepConf online free url in huggingface.co:
DeepConf is an open source model from GitHub that offers a free installation service, and any user can find DeepConf on GitHub to install. At the same time, huggingface.co provides the effect of DeepConf install, users can directly use DeepConf installed effect in huggingface.co for debugging and trial. It also supports api for free installation.