Generative AI with LangChain by Ben Auffarth
Author:Ben Auffarth
Language: eng
Format: epub
Tags: COM044000 - COMPUTERS / Neural Networks, COM058000 - COMPUTERS / Desktop Applications / Word Processing, COM042000 - COMPUTERS / Natural Language Processing
Publisher: Packt
Published: 2023-12-14T11:52:18+00:00
In this example, the window size is set to 1, meaning that only the last interaction will be stored in memory.
We can use the save_context() method to save the context of each interaction. It takes two arguments: user_input and model_output. These represent the userâs input and the corresponding modelâs output for a given interaction.
memory.save_context({"input": "hi"}, {"output": "whats up"}) memory.save_context({"input": "not much you"}, {"output": "not much"})
We can see the message with memory.load_memory_variables({}).
We can also customize the conversational memory in LangChain, which involves modifying the prefixes used for the AI and human messages, as well as updating the prompt template to reflect these changes.
To customize the conversational memory, you can follow these steps:
Import the necessary classes and modules from LangChain: from langchain.llms import OpenAI from langchain.chains import ConversationChain from langchain.memory import ConversationBufferMemory from langchain.prompts.prompt import PromptTemplate llm = OpenAI(temperature=0)
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Computer Vision & Pattern Recognition | Expert Systems |
Intelligence & Semantics | Machine Theory |
Natural Language Processing | Neural Networks |
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8295)
Test-Driven Development with Java by Alan Mellor(6697)
Data Augmentation with Python by Duc Haba(6601)
Principles of Data Fabric by Sonia Mezzetta(6358)
Learn Blender Simulations the Right Way by Stephen Pearson(6252)
Microservices with Spring Boot 3 and Spring Cloud by Magnus Larsson(6117)
Hadoop in Practice by Alex Holmes(5958)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5806)
RPA Solution Architect's Handbook by Sachin Sahgal(5517)
Big Data Analysis with Python by Ivan Marin(5347)
The Infinite Retina by Robert Scoble Irena Cronin(5217)
Life 3.0: Being Human in the Age of Artificial Intelligence by Tegmark Max(5143)
Pretrain Vision and Large Language Models in Python by Emily Webber(4305)
Infrastructure as Code for Beginners by Russ McKendrick(4069)
Functional Programming in JavaScript by Mantyla Dan(4037)
The Age of Surveillance Capitalism by Shoshana Zuboff(3946)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3784)
Embracing Microservices Design by Ovais Mehboob Ahmed Khan Nabil Siddiqui and Timothy Oleson(3585)
Applied Machine Learning for Healthcare and Life Sciences Using AWS by Ujjwal Ratan(3562)
