-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to design a system to provide long answers #102
Comments
Thanks @drawal1. We have that as a planned tutorial in the README (see section 4, within Advanced Demos). It's pretty simple actually but I agree with you having a concrete example will go a long way. Will see who on our end has cycles to do this quickly |
Btw I've been thinking of long-form answers for factoid questions, like "David Gregory inherited Kinnairdy castle. Kinnairdy castle has 5 floors. Therefore, the castle that David Gregory inherited has 5 floors." You mention "how to" questions though. If you think that will look different from what I have in mind, do you have one full example question + answer? |
Here is a how-to question from my specific domain with the exact answer and the truncated answer from DSPy: Question: How do I upgrade my RadiantOne Platform? DSPy truncated answer:
Exact answer:
Here is a general QA example using ChatGPT (3.5). Challenge is how to replicate this kind of answer quality for our own documents? Question: How do you build and train a deep neural network for playing video game pong from scratch? Answer: Environment Setup: Install Python and necessary libraries like TensorFlow, NumPy, and Gym. Import the necessary libraries. Preprocess the game frames to reduce the complexity of the input data. This usually involves resizing, converting to grayscale, and normalizing pixel values. Design the neural network architecture. Convolutional Neural Networks (CNNs) are commonly used for processing game frames. model = tf.keras.Sequential([ Define a training loop that uses reinforcement learning algorithms like Proximal Policy Optimization (PPO) or Deep Q-Networks (DQN). Here's a simplified example using PPO: model = PPO("CnnPolicy", env, verbose=1) Train the neural network by interacting with the environment. The agent collects experience, updates the policy, and improves its performance over time. Evaluate the trained model by running it in the environment and measuring its performance. Experiment with different hyperparameters (e.g., learning rate, network architecture, training duration) to optimize performance. Save the trained model weights to disk so that you can use them later for inference without retraining. Deployment: If desired, integrate the trained model into a game-playing application or use it to control a virtual game of Pong. Iterate on the training process, making improvements based on evaluation results and insights. Continuously monitor the model's performance and behavior. |
DSPy has a small default for max tokens. Override it to get a longer response: lm = dspy.OpenAI( |
@detaos that worked! I will now test scenarios where the long form answer is assembled from multiple short answers gathered from different contexts. I am not sure they fit within the DSP paradigm |
I guess the problem comes as a tradeoff to long prompts that are compiled by dspy. I switched to 16k model to deal with this. |
I am not sure how to train DSPy to synthesize long, detailed answers such as those are required for "how to" questions. So far, I have tried training on long examples with RAG and SimplifiedBaleen; and answer_exact_match frac set to different values ranging from 0.5-0.8
In all cases, the system truncates the answers or gives incomplete answers, even when the answers are retrieved fully formed in the context
What is needed is a way to retrieve the answers to the various questions, and then instead of selecting one answer (which is what Predict does), to build/assemble the final answer from the answers to all the sub-questions
I tried doing this using manual prompt engineering and langchain and it works great! Unfortunately, its complicated and requires special handling for questions that are more suitable for "factoid" answers
Are there any examples to demonstrate synthesizing long, detailed answers?
The text was updated successfully, but these errors were encountered: