百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
L

logits-processor-zoo

> AI 编程
开源

一个包含 LogitsProcessor 的集合,用于为特定任务自定义和增强 LLM 的行为。

388 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个包含 LogitsProcessor 的集合,用于为特定任务自定义和增强 LLM 的行为。

logits-processor-zoo

Struggling to get LLMs to follow your instructions? LogitsProcessorZoo offers a zoo of tools to use LLMs for specific tasks, beyond just grammar enforcement!

Installation

pip install logits-processor-zoo

Supported Frameworks

  • transformers
  • vLLM
  • TensorRT-LLM (>=0.20.0)

Usage

…

For the detailed examples in each framework, please have a look at lpz_examples directory.

vLLM serve with string tokenizers

When vLLM logits processors are configured through the HTTP API, processor kwargs come from the request body. If a processor receives tokenizer as a string, the server will only load it when the tokenizer name is explicitly allowlisted in the LOGITS_PROCESSOR_ZOO_VLLM_ALLOWED_TOKENIZERS environment variable. Tokenizers are loaded from local files only, so the tokenizer must already be available in the server environment.

LOGITS_PROCESSOR_ZOO_VLLM_ALLOWED_TOKENIZERS=Qwen/Qwen2.5-1.5B-Instruct \
  vllm serve Qwen/Qwen2.5-1.5B-Instruct \
  --dtype auto \
  --api-key lpz-test \
  --logits-processor-pattern "logits_processor_zoo.vllm"

Multiple trusted tokenizer names can be separated with commas.

Available Logits Processors

GenLengthLogitsProcessor

A logits processor that adjusts the likelihood of the end-of-sequence (EOS) token based on the length of the generated sequence, encouraging or discouraging shorter answers.

CiteFromPromptLogitsProcessor

A logits processor which boosts or diminishes the likelihood of tokens present in the prompt (and optionally EOS token) to encourage the model to generate tokens similar to those seen in the prompt or vice versa.

ForceLastPhraseLogitsProcessor

A logits processor which forces LLMs to use the given phrase before they finalize their answers. Most common use cases can be providing references, thanking user with context etc.

MultipleChoiceLogitsProcessor

A logits processor to answer multiple choice questions with one of the choices. A multiple choice question is like:

I am getting a lot of calls during the day. What is more important for me to consider when I buy a new phone?
0. Camera
1. Screen resolution
2. Operating System
3. Battery

The goal is to make LLM generate "3" as an answer.

TriggerPhraseLogitsProcessor

A logits processor which triggers phrases when it encounters a given token or after a specified time. One common use case is to force writing python code just after thinking:

trigger_python = TriggerPhraseLogitsProcessor(phrase="\n```python", trigger_token_phrase="", 
                                              tokenizer=tokenizer, trigger_count=1, trigger_after=True)

PreventHallucinationLogitsProcessor

A logits processor that mitigates hallucinated model outputs by enforcing a predefined fallback phrase when token confidence falls below a specified threshold.

MaxTimeLogitsProcessor

A logits processor that enforces the end-of-sentence (EOS) token after a specified maximum time passes, optionally waiting for a new line or a full stop. Useful for controlling generation time and ensuring responses complete within time constraints.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Pythonllmlogitspostprocessing

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类AI 编程
定价开源

> 相关工具

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.