Skip to content
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

Traceable Evals #1834

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Traceable Evals #1834

wants to merge 10 commits into from

Conversation

CyrusNuevoDia
Copy link
Collaborator

@CyrusNuevoDia CyrusNuevoDia commented Nov 21, 2024

  ,-~~-.___.
 / |  '     \
(  )         0
 \_/-, ,----'
    ====           //
   /  \-'~;    /~~~(O)
  /  __/~|   /       |
=(  _____| (_________|
from dspy.evaluate import tracer

@tracer
def number_to_bits(number):
    if number:
        bits = []
        while number:
            number, remainder = divmod(number, 2)
            bits.insert(0, remainder)
        return bits
    else:
        return [0]

str(number_to_bits.source) # source code with line numbers
"""
    1 | @tracer
    2 | def number_to_bits(number):
    3 |     if number:
    4 |         bits = []
    5 |         while number:
    6 |             number, remainder = divmod(number, 2)
    7 |             bits.insert(0, remainder)
    8 |         return bits
    9 |     else:
   10 |         return [0]
"""

number_to_bits(6)
str(number_to_bits.trace) # last execution with a trace like the one below
"""
 >>> Call to number_to_bits in File "...", line N
 ...... number = 6
    2 | def number_to_bits(number):
    3 |     if number:
    4 |         bits = []
    5 |         while number:
    6 |             number, remainder = divmod(number, 2)
 .................. number = 3
 .................. remainder = 0
    7 |             bits.insert(0, remainder)
 .................. bits = [0]
 .................. len(bits) = 1
    5 |         while number:
    6 |             number, remainder = divmod(number, 2)
 .................. number = 1
 .................. remainder = 1
    7 |             bits.insert(0, remainder)
 .................. bits = [1, 0]
 .................. len(bits) = 2
    5 |         while number:
    6 |             number, remainder = divmod(number, 2)
 .................. number = 0
    7 |             bits.insert(0, remainder)
 .................. bits = [1, 1, 0]
 .................. len(bits) = 3
    5 |         while number:
    8 |         return bits
 <<< Return value from number_to_bits: [1, 1, 0]
"""

Kudos to the wonderful https://github.com/alexmojaki/snoop

@CyrusNuevoDia CyrusNuevoDia changed the title Snoopable Evals Snoopy Evals Nov 21, 2024
@CyrusNuevoDia CyrusNuevoDia marked this pull request as ready for review November 21, 2024 21:09
@CyrusNuevoDia CyrusNuevoDia requested a review from okhat November 21, 2024 21:09
@CyrusNuevoDia
Copy link
Collaborator Author

Weird, tests pass locally for me but fail in the CI/CD. Also, the tests have nothing to do with what I've changed.

@mikeedjones
Copy link
Contributor

mikeedjones commented Nov 25, 2024

The version of pydantic? there was a release to 2.10 recently. Looks like tests are failing when trying to work with pydantic models.

Looks like there's been a change to the way model_fields is created https://github.com/pydantic/pydantic/pull/10493/files

I'll make a fix to replace.

@mikeedjones
Copy link
Contributor

mikeedjones commented Nov 25, 2024

Can you try with: #1855 please?

@CyrusNuevoDia
Copy link
Collaborator Author

@mikeedjones it works now!

@CyrusNuevoDia CyrusNuevoDia changed the title Snoopy Evals Traceable Evals Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants