{"id":22143291,"url":"https://github.com/paritoshk/anysphere_test","last_synced_at":"2025-03-24T11:43:42.613Z","repository":{"id":257701063,"uuid":"859058926","full_name":"paritoshk/anysphere_test","owner":"paritoshk","description":" \"speculative edits\" using pytorch and huggingface with temperature 0 (greedy sampling)","archived":false,"fork":false,"pushed_at":"2024-09-18T04:04:15.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-29T17:11:37.635Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paritoshk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-18T02:26:30.000Z","updated_at":"2024-11-05T13:03:06.000Z","dependencies_parsed_at":"2024-09-18T06:37:24.715Z","dependency_job_id":"a889af34-92c5-4c1c-a1f2-b7c237a1677f","html_url":"https://github.com/paritoshk/anysphere_test","commit_stats":null,"previous_names":["paritoshk/anysphere_test"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritoshk%2Fanysphere_test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritoshk%2Fanysphere_test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritoshk%2Fanysphere_test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritoshk%2Fanysphere_test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paritoshk","download_url":"https://codeload.github.com/paritoshk/anysphere_test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245267211,"owners_count":20587455,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-01T22:08:47.734Z","updated_at":"2025-03-24T11:43:42.593Z","avatar_url":"https://github.com/paritoshk.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Speculative Edits\n\n## Problem\nYour goal is to implement \"speculative edits\" using pytorch and huggingface with temperature 0 (greedy sampling)\n\nWe describe speculative edits in brief detail near the end of [this blog post](https://cursor.sh/blog/instant-apply).\n\nTo summarize: \n\nInstead of a draft model producing draft tokens (as in done in speculative edits), we manually produce the draft tokens ourselves since we have a strong prior on generated tokens for sparse edits represented as rewrites.\n\n\nConsider the following prompt:\n````txt\nPlease add a single comment\n\n```ts\nexport default function Visualization() {\n  const [instanceIdInputs, setInstanceIdInputs] = createSignal\u003c\n    InstanceId[] | null\n  \u003e(null);\n  const [storedInput, setStoredInput] = createSignal\u003cstring\u003e(\"\");\n  const [datapointOptions, setDatapointOptions] = createSignal\u003cPropsInstance[]\u003e(\n    []\n  );\n  const [shouldRefreshGold, setShouldRefreshGold] =\n    createSignal\u003cboolean\u003e(false);\n  const [showGold, setShowGold] = createSignal\u003cboolean\u003e(false);\n  const [selectedGoldRequestId, setSelectedGoldRequestId] = createSignal\u003c\n    string | undefined\n  \u003e(undefined);\n  const [goldInstances, setGoldInstances] = createSignal\u003c\n    {\n      sessionId: string;\n      email: string | undefined;\n      requestId: string | undefined;\n      dateAdded: Date;\n      type: $Enums.CppGoldExampleType;\n    }[]\n  \u003e([]);\n}\n```\n\n```ts\n````\n\nYou should be able to generate this code much faster than vanilla token generation\nwith speculative edits. Why?\n\nA sample generated response is:\n````\nexport default function Visualization() {\n  const [instanceIdInputs, setInstanceIdInputs] = createSignal\u003c\n    InstanceId[] | null\n  \u003e(null);\n  const [storedInput, setStoredInput] = createSignal\u003cstring\u003e(\"\");\n  const [datapointOptions, setDatapointOptions] = createSignal\u003cPropsInstance[]\u003e(\n    []\n  );\n  const [shouldRefreshGold, setShouldRefreshGold] =\n    createSignal\u003cboolean\u003e(false);\n  const [showGold, setShowGold] = createSignal\u003cboolean\u003e(false);\n  const [selectedGoldRequestId, setSelectedGoldRequestId] = createSignal\u003c\n    string | undefined\n  \u003e(undefined);\n  # This is a comment\n  const [goldInstances, setGoldInstances] = createSignal\u003c\n    {\n      sessionId: string;\n      email: string | undefined;\n      requestId: string | undefined;\n      dateAdded: Date;\n      type: $Enums.CppGoldExampleType;\n    }[]\n  \u003e([]);\n}\n```\n````\n\nOn the first forward pass, we can feed in the entire original code block as a speculation. Then we start generating tokens when the model disagrees with our draft. (at the line `# this is a comment`). Eventually, we'll want to re-speculate on the remainder of the prompt.\nNote that the choice of greedy sampling simplifies things.\n\nIf developing locally, we'd recommend using a small model like `gpt-2`.\n\nIf you would like to test real performance on smarter models before submission, you may use the card provided in the form to purchase $10 worth of GPU-hours. We'd recommend 3090s or 4090s on [Runpod](https://runpod.io), but any machine with \u003e18GB of GPU RAM will suffice.\n\nA good model to test would be `llama-3-8b-instruct` or `deepseek-coder-6.7b-instruct`.\n## Submission Instructions\nWhen finished, please zip this folder and upload the zipfile to this form: https://docs.google.com/forms/d/1COjBZBA5jSxpaLtBZlD-ktAS0LnWbiH4LfyUgzowgpg/edit\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparitoshk%2Fanysphere_test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparitoshk%2Fanysphere_test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparitoshk%2Fanysphere_test/lists"}