Langchain Flashcards

(9 cards)

1
Q

how to restart kernal in python

A

Import os
os.exit(00)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Langchain core components

A

Open source interface that simplifies app development using LLM

Documents,
chains ,
agents ,
language model,
chat model ,
chat message,
prompt template and
output parsers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Language model

A

Language model in langchain is the Foundation of LLMs. It uses text input to generate text outputs , and hep to compete tasks and summarize documents.

Langchain uses IBM, OpenAI, google and meta as primary language models

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Chat model and language model

A

A chat model is designed for efficient conversations. It means it understands the questions or prompts , and respond like a human being . next to generate response , create a language model using IBM/Open AI and transform the model into chat model using LLM function . This converts chat model into conversational LLM to engage in dialogues

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Chat messages

A

Chat Model creates list of chat messages - system, human and AI

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Prompt templates

A

Prompt templates translates user questions or messages into clear instructions.

String prompt templates - useful for single string formatting

Chat prompt templates - useful for message lists

Specific message prompt templates ( AI MPT, Human MPT, System MPT and chat MPT) allows for flexible role assignments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Few shot prompt template

A

Semantic similarity, max margin relevance for diversity, examples of Efficient prompts, and N gram overlap for textual similarity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Output parsers

A

Ouput parsers allows converting / transforms output to desired output in specific layout (json, xml, csv, pandas)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

LLM chain

A

Overall chain

Template string —> create prompt template —> create LLM chain object

from langchain.chains import LLMChain,SequentialChain

template = “””” suggest dish {location} “””
prompt_template= PromptTemplate (template =template, input_variables =[‘location’])

chain_loc = LLMChain( LLM=mistral_llm, prompt =prompt_template , output_key=‘meal’)

Create similar chain #2 where input is key for second template

Overall_chain = SequentialChain(chains=[chain_loc, chain_2],Input_variable =[‘location’],
Output_variables=[‘meal’,’chain2output’], verbose=True)

Overall_chain.invoke(input={‘location’:’china’})

How well did you know this?
1
Not at all
2
3
4
5
Perfectly