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

[Feature]: Implement and test speculative editing #1854

Open
neubig opened this issue May 17, 2024 · 4 comments
Open

[Feature]: Implement and test speculative editing #1854

neubig opened this issue May 17, 2024 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers severity:medium Problems that affect many users

Comments

@neubig
Copy link
Contributor

neubig commented May 17, 2024

What problem or use case are you trying to solve?

File editing is not perfect with our current method using SWE-Agent style actions.

Do you have thoughts on the technical implementation?

Cursor has recently published work on speculative editing, that we could possibly incorporate into our agent workflows: https://cursor.sh/blog/instant-apply

We would want to implement a prototype and benchmark it against SWE-Bench.

This would be a good issue for new contributors who have significant experience with LLMs and agents!

@neubig neubig added enhancement New feature or request good first issue Good for newcomers labels May 17, 2024
@neubig neubig changed the title [Feature]: Try Speculative Editing [Feature]: Implement and test speculative editing May 17, 2024
@rbren rbren added the severity:medium Problems that affect many users label May 18, 2024
@JeffKatzy
Copy link

@neubig I'm interested in this, can take a look at this, this weekend.

@JeffKatzy
Copy link

@neubig Ok, so I think the easiest approach would be to implement this with huggingface's assistant model feature.

I found some references to this with whisper, and another hf blog here.

So would a valid implementation be to use a hf model, with an assistant model, and then update the do_completion call here, so that it can use the assistant. And then benchmark against using without an assistant?

One downside of using hf is it does not look there's a way to make it compatible with non-hf models like gpt-4, etc. I looked to see if there was a way to implement a hf model wrapper, but didn't see a solution.

@neubig
Copy link
Contributor Author

neubig commented May 28, 2024

Hmm, I'm a bit confused. I think the main difference that we would need to have is that we would need to generate edits in the diff format like that cited on the blog:

@@ ... @@
 function binarySearch(arr, x) {
-    let low = 0, high = arr.length - 1;
-    while (low <= high) {
-        let mid = Math.floor((low + high) / 2);
-        if (arr[mid] === x) {
-            return mid;
-        }
-        low += 1;
-    }
-    return -1;
+    let low = 0, high = arr.length - 1;
+    while (low <= high) {
+        let mid = Math.floor((low + high) / 2);
+        if (arr[mid] === x) {
+            return mid;
+        } else if (arr[mid] < x) {
+            low = mid + 1;
+        } else {
+            high = mid - 1;
+        }
+    }
+    return -1;
 }

I'm not sure how this has something to do with the assistant feature on hugging face. Could you elaborate more?

@JeffKatzy
Copy link

JeffKatzy commented May 28, 2024

Ok, that helps. I was looking at the implementation portion, where they talk about speculative decoding in the blog post.

"We achieve speeds of >1000 tokens/s (just under 4000 char/s) on our 70b model using a speculative-decoding variant tailored for code-edits, called speculative edits."

"Our biggest win comes from our custom speculative decoding algorithm called “speculative edits”. It is equivalent to a full-file-rewrite, while being up to 9x faster."

And the assistant model is how speculative decoding works with huggingface.

Ok, so now I get that you are talking about generating edits in a diff format. I'll look into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers severity:medium Problems that affect many users
Projects
None yet
Development

No branches or pull requests

3 participants