| |
|
|
| |
| |
| |
| |
|
|
| |
| |
| |
| |
|
|
| |
| |
| import pprint |
| import requests |
| import json |
| import os |
| from dotenv import load_dotenv |
| load_dotenv() |
|
|
| api_key = os.getenv("API_KEY") |
|
|
| from openai import OpenAI |
|
|
| client = OpenAI( |
| base_url = "https://integrate.api.nvidia.com/v1", |
| api_key = api_key |
| ) |
|
|
| prologue= """given guile scheme code, wrapped in a json frame,""" |
| tasks = [ |
| "Describe the code", |
| "break into two parts", |
| "classify the complexity", |
| "classify the funcitionality", |
| "create a list of propositions about the code", |
| "create a list of questions", |
| "create a proof", |
| "create a question and answer about the code", |
| "create a test harness", |
| "create challenge", |
| "create coq language lemmas", |
| "create list of question about the code", |
| "create list of question and answers about the code", |
| "describe the co-domain of the function", |
| "describe the domain of the function", |
| "describe the postconditions of the function", |
| "describe the postconditions of the function", |
| "describe the preconditions of the function", |
| "extract a coq proof about this code", |
| "extract a list of dependencies", |
| "extract a list of prerequisites", |
| "extract a list of types of data in the code", |
| "extract verifiable propositions" |
| "reify the code into a reflective meta description", |
| "reify the code", |
| "introspect over the code ", |
| "reflect over the code ", |
| "inspect the code carefully", |
| "construct a mathematical formula that describes the complexity", |
| "construct a mathematical formula that describes the runtime", |
| "simulate the execution of the code", |
| "simulate the runtime of the code", |
| "translate into c++ ", |
| "translate into c++ meta template code", |
| "translate into python ", |
| "translate into rdf/owl ontology ", |
| "translate into rdf/owl ontology in turtle format ", |
| "translate to coq", |
| "translate to emojis", |
| "translate to haskell", |
| "translate to json", |
| "translate to ocaml", |
| "translate to python", |
| "translate to template haskell", |
| "translate to yaml", |
| "what are some smart questions we can ask about this code", |
| "write code that will split this code into parts", |
| |
| ] |
|
|
| from datasets import load_dataset |
| dataset = load_dataset("arrow", |
| data_files={'input': 'dataset/data-00000-of-00001.arrow'}) |
| for example in dataset["input"]: |
|
|
| data = json.dumps(example) |
| if "(define " not in data: |
| continue |
| for model in [ |
| "meta/llama3-70b-instruct", |
| "google/gemma-2-9b-it", |
| "nvidia/nemotron-4-340b-instruct", |
| "snowflake/arctic", |
| "microsoft/phi-3-medium-128k-instruct"]: |
| for task in tasks: |
| for temp in [0.1,0.3,0.5,0.7,0.9]: |
| try: |
| completion = client.chat.completions.create( |
| model=model, |
| messages=[{"role":"user","content":prologue + "," + task + " input: "+ data}], |
| temperature=temp, |
| top_p=0.7, |
| max_tokens=4024, |
| stream=True |
| ) |
| |
| chunks = [] |
| for chunk in completion: |
| if chunk.choices[0].delta.content is not None: |
| |
| |
| chunks.append( |
| |
| chunk.choices[0].delta.content) |
| |
| result = dict( |
| inputs = data, |
| chunks = "".join(chunks), |
| temp=temp, |
| module = model, |
| task = task, |
| ) |
| print(json.dumps(result)) |
| except Exception as e: |
| print(e) |
|
|