mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-10 11:55:11 +03:00
4.6 KiB
4.6 KiB
In [ ]:
%pip install "xinference[all]"In [13]:
!xinference launch -n vicuna-v1.3 -f ggmlv3 -q q4_0Model uid: 7167b2b0-2a04-11ee-83f0-d29396a3f064
In [14]:
from langchain.llms import Xinference
llm = Xinference(
server_url="http://0.0.0.0:9997",
model_uid = "7167b2b0-2a04-11ee-83f0-d29396a3f064"
)
llm(
prompt="Q: where can we visit in the capital of France? A:",
generate_config={"max_tokens": 1024, "stream": True},
)Out [14]:
' You can visit the Eiffel Tower, Notre-Dame Cathedral, the Louvre Museum, and many other historical sites in Paris, the capital of France.'
In [16]:
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
template = "Where can we visit in the capital of {country}?"
prompt = PromptTemplate(template=template, input_variables=["country"])
llm_chain = LLMChain(prompt=prompt, llm=llm)
generated = llm_chain.run(country="France")
print(generated)A: You can visit many places in Paris, such as the Eiffel Tower, the Louvre Museum, Notre-Dame Cathedral, the Champs-Elysées, Montmartre, Sacré-Cœur, and the Palace of Versailles.
In [17]:
!xinference terminate --model-uid "7167b2b0-2a04-11ee-83f0-d29396a3f064"