NVIDIA / NVIDIA/GenerativeAIExamples
langchain_nvidia_trt not working
未关闭
@shubhadeepd 已经在做这个了。
开始于 2024年4月22日。
question
- 主要语言
- Jupyter Notebook
- 星标
- 4.2k
- 派生
- 1.1k
- 平均合并
- 10 小时 15 分钟
- 30 天内合并 PR
- 1
描述
I have gone through the notebooks but couldn't able to stream the tokens from the TensorRTLLM.
Here's the issue:
Code used:
from langchain_nvidia_trt.llms import TritonTensorRTLLM
import time
import random
triton_url = "localhost:8001"
pload = {
'tokens':300,
'server_url': triton_url,
'model_name': "ensemble",
'temperature':1.0,
'top_k':1,
'top_p':0,
'beam_width':1,
'repetition_penalty':1.0,
'length_penalty':1.0
}
client = TritonTensorRTLLM(**pload)
LLAMA_PROMPT_TEMPLATE = (
"<s>[INST] <<SYS>>"
"{system_prompt}"
"<</SYS>>"
"[/INST] {context} </s><s>[INST] {question} [/INST]"
)
system_prompt = "You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Please ensure that your responses are positive in nature."
context=""
question='What is the fastest land animal?'
prompt = LLAMA_PROMPT_TEMPLATE.format(system_prompt=system_prompt, context=context, question=question)
start_time = time.time()
tokens_generated = 0
for val in client._stream(prompt):
tokens_generated += 1
print(val, end="", flush=True)
total_time = time.time() - start_time
print(f"\n--- Generated {tokens_generated} tokens in {total_time} seconds ---")
print(f"--- {tokens_generated/total_time} tokens/sec")
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
评估
这个 Issue 还没有评估数据。