LLM

Types:

  • Base LLM - predict the next word based on text training data

  • Instruction Tuned LLM - has been trained to follow instructions

Misc References

Persona or Role

  • Answer this question as if you were a rude store attendant. Question: where are the carrots?

chevron-rightDefault Rolehashtag
[
 {'role':    'system', 
  'content': 'You are an assistant'},    
 {'role':    'user', 
  'content': 'write me a very short poem about a happy carrot'},
]
chevron-rightUsing role to Control context, length, and combined hashtag
[
 {'role':    'system', 
  'content': 'You are an assistant who responds\
                in the style of Dr Seuss.'},    
 {'role':    'user',
  'content': 'write me a very short poem about a happy carrot'}, 
]
[
 {'role':    'system', 
  'content': 'All your responses must be one sentence long.},    
 {'role':    'user',
  'content': 'write me a very short poem about a happy carrot}, 
]
[
 {'role':   'system',
 'content': 'You are an assistant who responds in the style\
               of Dr Seuss. All your responses must be\
               one sentence long.'},    
{'role':    'user',
 'content': 'write me a story about a happy carrot'},
]

Moderation & Detect Prompt injection

  • Use openai Moderation API

  • Use delimiters to guard against malicious prompt injection

chevron-rightDelimiters and Guard against Prompt injectionhashtag

Inference

Use cases: extracting labels, extracting names, sentiment analysis, etc.

chevron-rightSentimenthashtag

Extract

Use cases: extract information from text

chevron-rightExtract information from text hashtag

Classification

chevron-rightUse case: Customer service assistanthashtag

Task: classify many different instructions to handle different cases

Chain of Thought Reasoning

chevron-rightUse case: Customer product inquiry, ask directlyhashtag
chevron-rightUse case: Customer product inquiry, using few-shot reasoninghashtag

Use case: answer the customer query using the provided product list

chevron-rightUse case: Customer product inquiry, combine product info for external sourcehashtag

NOTE: there are also more advanced techniques for information retrieval (i.e., filtered_product_info). One of the most effective ways to retrieve information is using text embeddings. And embeddings can be used to implement efficient knowledge retrieval over a large corpus to find information related to a given query. One of the key advantages of using text embeddings is that they enable fuzzy or semantic search, which allows you to find relevant information without using the exact keywords. So in our example, we wouldn't necessarily need the exact name of the product, but we could do a search with a more general query like a mobile phone.

QA Validation

chevron-rightExample: Q&A validationhashtag
chevron-rightExample: evaluate whether the response is sufficient & met facts hashtag
chevron-rightUsing rubrichashtag
chevron-rightOpenAI Eval patternhashtag

Last updated