This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pydantic import BaseModel, Field | |
from typing import Optional | |
import dspy | |
from dspy.experimental import SyntheticDataGenerator | |
llm = dspy.OpenAI(model='gpt-3.5-turbo',api_key=openai_key) | |
dspy.settings.configure(lm=llm) | |
class RPGPlayer(BaseModel): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dspy | |
from dspy.experimental import SyntheticDataGenerator | |
from pydantic import BaseModel, Field | |
llm = dspy.OpenAI(model='gpt-3.5-turbo',api_key=openai_key) | |
dspy.settings.configure(lm=llm) | |
class SyntheticFacts(BaseModel): | |
fact: str = Field(..., description="a statement") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pydantic import BaseModel | |
import dspy | |
import random | |
def synthetic_data_generation(schema_class: BaseModel, sample_size: int): | |
class_name = f"{schema_class.__name__}Signature" | |
# Fetch schema information | |
data_schema = schema_class.model_json_schema() | |
properties = data_schema['properties'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Synthetic Prompt Optimization | |
from dspy.teleprompt import BootstrapFewShot | |
from dspy.evaluate import answer_exact_match | |
text = "Barack Obama was not President of the USA" | |
# define the fact as input to the lie detector | |
trainset = [x.with_inputs('fact') for x in few_shot_examples] | |
# define the signature to be used in by the lie detector module |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Synthetic data generation using DSPy | |
from typing import List | |
import dspy | |
llm = dspy.OpenAI(model='gpt-3.5-turbo',api_key=openai_key) | |
dspy.settings.configure(lm=llm) | |
class FactGeneration(dspy.Signature): | |
"""Generate facts and their veracity""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Synthetic data generation using DSPy | |
from typing import List | |
import dspy | |
llm = dspy.OpenAI(model='gpt-3.5-turbo',api_key=openai_key) | |
dspy.settings.configure(lm=llm) | |
class FactGeneration(dspy.Signature): | |
"""Generate facts and their veracity, it should be different than old data""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import yfinance as yf | |
from yahooquery import Ticker | |
import warnings | |
# Ignore all warnings | |
warnings.filterwarnings('ignore') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dspy | |
llm = dspy.OpenAI(model='gpt-3.5-turbo',api_key=openai_key) | |
dspy.settings.configure(lm=llm) | |
# Implementation of a lie detector without optimization | |
text = "Barack Obama was not President of the USA" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import pandas as pd | |
from data_generation import generate_dataset, generate_parts_of_dataset | |
# Sidebar with company logo and use case navigation | |
# Use Markdown to increase font size for the title | |
st.sidebar.markdown(""" | |
<style> | |
.big-font { | |
font-size:20px !important; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from dotenv import load_dotenv | |
from pydantic import BaseModel, create_model | |
from typing import List, Any, Type | |
from anonLLM.llm import OpenaiLanguageModel | |
load_dotenv() | |
llm = OpenaiLanguageModel(anonymize=False, temperature=1) |