Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Supports LoRA for LLM and image models #1080

Merged
merged 2 commits into from Mar 8, 2024

Conversation

ChengjieLi28
Copy link
Contributor

@ChengjieLi28 ChengjieLi28 commented Mar 5, 2024

Related #389
Fixes #271
Fixes #840
Fixes #1041

Example

Image model

  1. Download lora from repo: https://huggingface.co/shiroppo/sd_xl_turbo_lora
  2. Use sdxl-turbo
from xinference.client import Client
client = Client("http://127.0.0.1:12306")
model_uid = client.launch_model(model_name="sdxl-turbo", model_type="image", peft_model_path='/home/lichengjie/lora/sd_xl_turbo_lora', image_lora_load_kwargs={"weight_name": "sd_xl_turbo_lora_v1-64dim.safetensors"})
model = client.get_model('sdxl-turbo')
model.text_to_image("papercut, a dragon", size="256*256")
image

LLM model

  1. Download lora from repo: https://huggingface.co/Jungwonchang/Ko-QWEN-7B-Chat-LoRA
  2. Use qwen-chat 7B:
from xinference.client import Client
client = Client("http://127.0.0.1:12306")
model_uid = client.launch_model(model_name="qwen-chat", model_format="pytorch", model_size_in_billions=7, quantization="none", n_gpu=1, model_type="LLM", peft_model_path='/home/lichengjie/lora/qwen')
model = client.get_model(model_uid)
model.chat("농구의 간략한 역사")
image

The answer is:

농구는 19세기 후반 미국에서 발명되었으며, 그 원래 목적은 재활용 골프 체육을 위한 것이었습니다. 1891년 캐나다 출신의 학교 교사인 제임스 나이스미스가 창시하고 프레드 시만이 개발했습니다.\r\n\r\n처음에는 주로 남성들이 즐겨 하는 스포츠였지만, 이후 여성에게도 점점 인기를 얻고 있습니다. 오늘날 농구는 전 세계적으로 가장 인기 있는 스포츠 중 하나이며, NBA와 같은 Professional 농구 리그를 비롯한 수많은 국내 및 해외 리그가 있습니다.\r\n\r\n농구의 역사상 가장 유명한 선수로는 마리오 다니엘스, 칼 지글러, 매직 존슨, 셀 레이 등이 있으며, 각자의 기록과 업적으로 농구 역사에 이름을 올렸습니다.\r\n\r\n전반적으로 농구는 시간이 지남에 따라 진화하고 변화해 왔으며, 오늘날까지도 계속해서 많은 사람들에게 사랑받고 인기 있는 스포츠입니다.

Without lora, qwen-chat 7B's Korean language ability is very weak. With Korean-enhanced lora, Korean answers are very smooth.

@XprobeBot XprobeBot added this to the v0.9.2 milestone Mar 5, 2024
@XprobeBot XprobeBot added the gpu label Mar 5, 2024
@ChengjieLi28 ChengjieLi28 marked this pull request as ready for review March 6, 2024 03:18
@qingjiaozyn
Copy link

Related #389 Fixes #271 Fixes #840 Fixes #1041

Example

Image model

  1. Download lora from repo: https://huggingface.co/shiroppo/sd_xl_turbo_lora
  2. Use sdxl-turbo
from xinference.client import Client
client = Client("http://127.0.0.1:12306")
model_uid = client.launch_model(model_name="sdxl-turbo", model_type="image", peft_model_path='/home/lichengjie/lora/sd_xl_turbo_lora', image_lora_load_kwargs={"weight_name": "sd_xl_turbo_lora_v1-64dim.safetensors"})
model = client.get_model('sdxl-turbo')
model.text_to_image("papercut, a dragon", size="256*256")
image ## LLM model 1. Download lora from repo: https://huggingface.co/Jungwonchang/Ko-QWEN-7B-Chat-LoRA 2. Use `qwen-chat` 7B:
from xinference.client import Client
client = Client("http://127.0.0.1:12306")
model_uid = client.launch_model(model_name="qwen-chat", model_format="pytorch", model_size_in_billions=7, quantization="none", n_gpu=1, model_type="LLM", peft_model_path='/home/lichengjie/lora/qwen')
model = client.get_model(model_uid)
model.chat("농구의 간략한 역사")
image The answer is:
농구는 19세기 후반 미국에서 발명되었으며, 그 원래 목적은 재활용 골프 체육을 위한 것이었습니다. 1891년 캐나다 출신의 학교 교사인 제임스 나이스미스가 창시하고 프레드 시만이 개발했습니다.\r\n\r\n처음에는 주로 남성들이 즐겨 하는 스포츠였지만, 이후 여성에게도 점점 인기를 얻고 있습니다. 오늘날 농구는 전 세계적으로 가장 인기 있는 스포츠 중 하나이며, NBA와 같은 Professional 농구 리그를 비롯한 수많은 국내 및 해외 리그가 있습니다.\r\n\r\n농구의 역사상 가장 유명한 선수로는 마리오 다니엘스, 칼 지글러, 매직 존슨, 셀 레이 등이 있으며, 각자의 기록과 업적으로 농구 역사에 이름을 올렸습니다.\r\n\r\n전반적으로 농구는 시간이 지남에 따라 진화하고 변화해 왔으며, 오늘날까지도 계속해서 많은 사람들에게 사랑받고 인기 있는 스포츠입니다.

Without lora, qwen-chat 7B's Korean language ability is very weak. With Korean-enhanced lora, Korean answers are very smooth.

Hello, I'm patrolling xinference in xinference 0.9.1 to load lora, below is my running code.

from xinference.client import Client

client = Client("http://120.48.137.80:9997")
model_uid = client.launch_model(model_name="qwen-14B-chat-base",
model_format="pytorch",
model_size_in_billions=14,
quantization="none",
n_gpu=2,
model_type="LLM",
peft_model_path='/home/zyn/checkpoint-4200')
model = client.get_model(model_uid)
query = """
how are you?
"""
reponse = model.chat(query)
print(reponse)

There are no parameters “peft_model_path” displayed when the model is launched
The following error message is displayed
image

and I looked at the source code and it really doesn't have this parameter

@ChengjieLi28
Copy link
Contributor Author

Hello, I'm patrolling xinference in xinference 0.9.1 to load lora, below is my running code.

This PR will be merged for the release of v0.9.2. Currently for v0.9.1, there is no peft_model_path parameter for the whole project...

@aresnow1 aresnow1 merged commit 45a8625 into xorbitsai:main Mar 8, 2024
11 of 12 checks passed
@qingjiaozyn
Copy link

Hello, I'm patrolling xinference in xinference 0.9.1 to load lora, below is my running code.

This PR will be merged for the release of v0.9.2. Currently for v0.9.1, there is no peft_model_path parameter for the whole project...

Xinference loads the Qwen LoRa model without VLLM acceleration

@ChengjieLi28
Copy link
Contributor Author

Hello, I'm patrolling xinference in xinference 0.9.1 to load lora, below is my running code.

This PR will be merged for the release of v0.9.2. Currently for v0.9.1, there is no peft_model_path parameter for the whole project...

Xinference loads the Qwen LoRa model without VLLM acceleration

Currently xinference does not support LoRA for vLLM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

支持Lora模型加载 Is fine-tuning the model supported? Such as Lora FEAT: support LoRA
4 participants