form a chain.from langchain.prompts import PromptTemplatetemplate = """Question: {question}Answer: Let's think step by step."""prompt = PromptTemplate.from_template(template)chain = prompt | llmquestion = "What is electroencephalography?"print(chain.invoke({"question": question}))Batch GPU Inference‚ÄãIf running on a device with GPU, you can also run inference on the GPU in batch mode.gpu_llm = HuggingFacePipeline.from_model_id(    model_id="bigscience/bloom-1b7",    task="text-generation",    device=0,  # -1 for CPU    batch_size=2,  # adjust as needed based on GPU map and model size.    model_kwargs={"temperature": 0, "max_length": 64},)gpu_chain = prompt | gpu_llm.bind(stop=["\n\n"])questions = []for i in range(4):    questions.append({"question": f"What is the number {i} in french?"})answers = gpu_chain.batch(questions)for answer in answers:    print(answer)PreviousHugging Face HubNextHuggingface TextGen InferenceLoad the modelCreate ChainBatch GPU InferenceCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.
Hugging Face models can be run locally through the HuggingFacePipeline class.
Hugging Face models can be run locally through the HuggingFacePipeline class. ->: form a chain.from langchain.prompts import PromptTemplatetemplate = """Question: {question}Answer: Let's think step by step."""prompt = PromptTemplate.from_template(template)chain = prompt | llmquestion = "What is electroencephalography?"print(chain.invoke({"question": question}))Batch GPU Inference‚ÄãIf running on a device with GPU, you can also run inference on the GPU in batch mode.gpu_llm = HuggingFacePipeline.from_model_id(    model_id="bigscience/bloom-1b7",    task="text-generation",    device=0,  # -1 for CPU    batch_size=2,  # adjust as needed based on GPU map and model size.    model_kwargs={"temperature": 0, "max_length": 64},)gpu_chain = prompt | gpu_llm.bind(stop=["\n\n"])questions = []for i in range(4):    questions.append({"question": f"What is the number {i} in french?"})answers = gpu_chain.batch(questions)for answer in answers:    print(answer)PreviousHugging Face HubNextHuggingface TextGen InferenceLoad the modelCreate ChainBatch GPU InferenceCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.