Fine-tuning Workflow: Define Target Behavior: Clearly identify the specific task, style, or format you want the model to learn.
Fine-tuning Workflow: Data Collection: Gather high-quality, representative examples of the desired input/output pairs. Aim for hundreds to thousands of examples.
Fine-tuning Workflow: Data Formatting: Convert your data into OpenAI's required JSONL (JSON Lines) format, where each line is a JSON object representing a conversation. Example: {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is the capital of France?"}, {"role": "assistant", "content": "Paris."}]}.
Fine-tuning Workflow: Upload Training Data: Use the OpenAI API to upload your formatted JSONL file as a training file.
Fine-tuning Workflow: Create Fine-tuning Job: Initiate a fine-tuning job via the API, specifying your uploaded file and the base model (e.g., gpt-3.5-turbo).
Fine-tuning Workflow: Monitor Job Status: Track the fine-tuning job's progress using the API. Training can take minutes to hours depending on data size.
Fine-tuning Workflow: Deploy and Test: Once complete, the API provides a new fine-tuned model ID. Use this ID in your chat completion requests.
Fine-tuning Workflow: Evaluate Performance: Compare the fine-tuned model's output against the base model for your specific task using a separate validation dataset.
Retrieval-Augmented Generation (RAG) Workflow: Identify Knowledge Source: Determine the external data sources (documents, databases, APIs) containing the information the model needs.
Retrieval-Augmented Generation (RAG) Workflow: Data Chunking: Break down large documents into smaller, semantically meaningful chunks (e.g., paragraphs, sections). This improves retrieval accuracy.
Retrieval-Augmented Generation (RAG) Workflow: Embeddings Generation: Convert each text chunk into a numerical vector (embedding) using an embedding model (e.g., text-embedding-ada-002). Embeddings capture the semantic meaning of the text.
Retrieval-Augmented Generation (RAG) Workflow: Vector Database Indexing: Store these embeddings in a vector database (e.g., Pinecone, Weaviate, ChromaDB) for efficient similarity search.
Retrieval-Augmented Generation (RAG) Workflow: User Query Embedding: When a user asks a question, convert their query into an embedding using the same embedding model.
Retrieval-Augmented Generation (RAG) Workflow: Similarity Search: Query the vector database with the user's embedding to find the most relevant text chunks from your knowledge base.
Retrieval-Augmented Generation (RAG) Workflow: Context Augmentation: Retrieve the original text content of the top-N most similar chunks.
Retrieval-Augmented Generation (RAG) Workflow: Prompt Construction: Inject these retrieved chunks into the ChatGPT API prompt as context, instructing the model to answer based only on the provided information.
Retrieval-Augmented Generation (RAG) Workflow: API Call and Response: Send the augmented prompt to the ChatGPT API and present the model's response to the user.