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

支持 BelleGroup/BELLE-LLAMA-7B-2M-gptq #12

Merged
merged 8 commits into from
Apr 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update chatglm.py
ypw committed Apr 1, 2023
commit 4f17b27c797c946ec40d2c5520583ca6cef7056e
11 changes: 8 additions & 3 deletions predictors/chatglm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from transformers import AutoModel, AutoTokenizer
import torch
import time
from typing import List, Tuple

import torch
from transformers import AutoModel, AutoTokenizer
from transformers import LogitsProcessor, LogitsProcessorList

from predictors.base import BasePredictor


@@ -19,6 +22,7 @@ class ChatGLM(BasePredictor):

def __init__(self, model_name):
print(f'Loading model {model_name}')
start = time.perf_counter()
self.device = 'cuda' if torch.cuda.is_available() else 'cpu'
self.tokenizer = AutoTokenizer.from_pretrained(
model_name, trust_remote_code=True, resume_download=True)
@@ -39,7 +43,8 @@ def __init__(self, model_name):
).half().to(self.device)
model = model.eval()
self.model = model
print(f'Successfully loaded model {model_name}')
end = time.perf_counter()
print(f'Successfully loaded model {model_name}, time cost: {end - start:.2f}s')

@torch.no_grad()
def stream_chat_continue(self,