# generate 方法res = llm.generate( prompts=[ "Explain the concept of large language models.", "What are the potential applications of AI in healthcare?", ])print(res)
Copy
# 流式传输for chunk in llm.stream("Describe the key features of the Yi language model series."): print(chunk, end="", flush=True)
Copy
# 异步流式传输import asyncioasync def run_aio_stream(): async for chunk in llm.astream( "Write a brief on the future of AI according to Dr. Kai-Fu Lee's vision." ): print(chunk, end="", flush=True)asyncio.run(run_aio_stream())
Copy
# 调整参数llm_with_params = YiLLM( model="yi-large", temperature=0.7, top_p=0.9,)res = llm_with_params( "Propose an innovative AI application that could benefit society.")print(res)