Lightning-AI / Lightning-AI/litgpt

Generating output from finetuned model using LLM.generate() method vs `litgpt chat` cli command

Open
#1,937 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted question
Dominant language
Python
Stars
13.7k
Forks
1.5k
Avg merge
15h 37m
Merged PRs (30d)
1

Description

I performed lora finetuning on Qwen2.5-3B-Instruct model on my custom dataset, and it seems that when I generate content using the `litgpt chat` cli interface the finetuned model performs flawlessly. However, when using it through the python api, following the [tutorial](https://github.com/Lightning-AI/litgpt/blob/main/tutorials/python-api.md#generatechat) the model outputs are random characters and basically rubbish. I tried using `litserve` and converting it into HuggingFace models but none worked.

Does anyone have any idea how to fix this.

P.S. Currently I am using a custom implementation of [`litgpt\chat\base.py`](https://github.com/Lightning-AI/litgpt/blob/main/litgpt/chat/base.py) to get my code working but this is pretty slow and I wish to parallelize the generation.

Thanks for any help.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Python API generate-chat tutorial and compare its generation path with litgpt/chat/base.py and the litgpt chat CLI. Reproduce the Qwen2.5-3B-Instruct LoRA case, checking why the Python API produces random characters while the CLI works. Done means the Python API generates coherent output consistent with the CLI without relying on a custom chat implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
ai, api, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.