be inside the function in notebooks    model_id = "facebook/bart-base"    tokenizer = AutoTokenizer.from_pretrained(model_id)    model = AutoModelForCausalLM.from_pretrained(model_id)    return pipeline("feature-extraction", model=model, tokenizer=tokenizer)def inference_fn(pipeline, prompt):    # Return last hidden state of the model    if isinstance(prompt, list):        return [emb[0][-1] for emb in pipeline(prompt)]    return pipeline(prompt)[0][-1]embeddings = SelfHostedEmbeddings(    model_load_fn=get_pipeline,    hardware=gpu,    model_reqs=["./", "torch", "transformers"],    inference_fn=inference_fn,)query_result = embeddings.embed_query(text)PreviousSageMakerNextSentence TransformersCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.
Let's load the SelfHostedEmbeddings, SelfHostedHuggingFaceEmbeddings, and SelfHostedHuggingFaceInstructEmbeddings classes.
Let's load the SelfHostedEmbeddings, SelfHostedHuggingFaceEmbeddings, and SelfHostedHuggingFaceInstructEmbeddings classes. ->: be inside the function in notebooks    model_id = "facebook/bart-base"    tokenizer = AutoTokenizer.from_pretrained(model_id)    model = AutoModelForCausalLM.from_pretrained(model_id)    return pipeline("feature-extraction", model=model, tokenizer=tokenizer)def inference_fn(pipeline, prompt):    # Return last hidden state of the model    if isinstance(prompt, list):        return [emb[0][-1] for emb in pipeline(prompt)]    return pipeline(prompt)[0][-1]embeddings = SelfHostedEmbeddings(    model_load_fn=get_pipeline,    hardware=gpu,    model_reqs=["./", "torch", "transformers"],    inference_fn=inference_fn,)query_result = embeddings.embed_query(text)PreviousSageMakerNextSentence TransformersCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.