r/MachineLearning • u/davidmezzetti • Sep 12 '20
Project [P] codequestion: Ask coding questions directly from the terminal
20
14
u/LaMifour Sep 12 '20
Nice. A friend and I thought of that few months ago. We dl the very same stack exchange zips and thought to use some text matching algo/comlands on it. The main caveats was storage. How much user storage do you use?
19
u/davidmezzetti Sep 12 '20
Thanks. With the compressed and uncompressed files, it's 100GB. The process only takes questions that have an accepted answer with at least 5 upvotes, which comes out to ~500k questions.
The pre-trained model is around 500MB compressed.
4
u/slomotion Sep 13 '20
How do you keep the model up-to-date?
1
u/davidmezzetti Sep 13 '20
Requires an index rebuild which is due. Most of the top questions are surprisingly old, at least for general programming questions.
12
u/Rex_In_Mundo Sep 12 '20
Great idea, but isn't 100 GB worth of space asking too much?
23
u/RoughMedicine Sep 12 '20
That's only for the training process. For users, you'll download a 542Mb zip file that becomes 1.3Gb uncompressed.
That file has the questions database (1Gb) and the ML model itself (embeddings and stuff).
8
u/LaMifour Sep 12 '20
Yes you are right. I installed codequestion on a 128gB ssd and was concerned but simple du command shows it takes 1.2GB of space uncompressed for the user!
6
u/davidmezzetti Sep 12 '20
Saw the note on uninstalling, please do file an issue (https://github.com/neuml/codequestion/issues) with what the expected behavior would be.
7
u/MuonManLaserJab Sep 12 '20
Cool!
There's also this: https://github.com/santinic/how2. Not sure how they compare.
11
u/davidmezzetti Sep 12 '20
That looks like a nice project. It's running a Google search and uses the Stack Overflow API to pull the selected answer. Simple/straightforward but effective approach.
codequestion can work online and offline since it has it's own index.
Thanks for sharing.
2
u/Craiglbl Sep 12 '20
Does the online part work similarly to the GitHub above (using APIs to directly search)?
I’m curious because most devs working with terminals have access to internet (since they might be running code on servers) so the offline part might not be used as frequently.
5
u/davidmezzetti Sep 12 '20
No API/network calls at all for codequestion, it runs a similarity search against a local Faiss index.
2
u/unrahul Sep 12 '20
really neat work, works like a charm on my 6 year old thinkpad. Thank you for describing the architecture as well, it's always enlightening to read and understand the thought process that went into building solutions such as this.
1
2
u/m3m3t Sep 12 '20
Very interesting! Just a heads up the if you enter a single letter (e.g. I typed in 'q' thinking that would exit the prompt) they Tokenizer.tokenize will return a query = [ ] which will cause an exception as the code will attempt to call Shell.do_q (or whatever letter you entered).
1
u/davidmezzetti Sep 12 '20
Thank you, issue created for this: https://github.com/neuml/codequestion/issues/15
2
u/pgdevhd Sep 12 '20
This would be great for offline development if you could have local storage of common results.
1
u/davidmezzetti Sep 13 '20
What do you envision with local storage of common results?
2
u/pgdevhd Sep 13 '20
Maybe just like an "offline" mode which doesn't require an internet connection. That would be very useful for people who need to lookup stackoverflow questions without a connection or working in a rural area.
2
u/JustOneAvailableName Sep 13 '20
No network connection is required once installed. The model executes similarity queries to find similar questions to the input query.
This is already a feature
1
2
u/ocramoidev Sep 13 '20
Damn, I have a telegram bot that does exactly this. Thank you for reminding me that this kind of stuff is welcomed here, I'll try to be more active in the sub. And nice work on the project! Keep it up!
1
2
u/super_saiyan1500 Sep 13 '20
Thanks for sharing! I really appreciate it when people share source for really interesting projects they're working on
1
2
u/thntk Sep 13 '20
Cool project! The MRR metrics are surprisingly high to me. I have tried very similar approach on different datasets (~104 documents), but never got that high results, and full-text search gave better results for me most of the time. Do you know why it works well here? I guess the queries and data must have some properties that favor this method. Would you mind explaining how you prepared the queries and evaluation data? I'm just curious.
2
u/davidmezzetti Sep 13 '20
Funny you mention that. I spent over two weeks trying to beat this method with a transformers model and was unable to.
https://github.com/neuml/codequestion/issues/8
The weighting of the tag tokens really help build a good embeddings object.
In terms of the evaluation data, I took 100 queries and manually ran them through google for stack exchange sites, and took the database id of the top result.
2
u/thntk Sep 13 '20
Thanks for the information. Interesting. I also used FastText, but weighted with TF-IDF instead of BM25, but in the end never got a satisfying result. I can see that the tags play a significant role in this dataset.
How many principle components did you remove? Does the number of principle components cause a big difference?
2
2
2
2
2
u/HybridRxN Researcher Sep 16 '20 edited Sep 16 '20
What is the difference between codequestion and the popular library howdoi with 8.4k stars?
1
u/davidmezzetti Sep 17 '20
howdoi runs a Google search for Stack Exchange sites and returns the result.
codequestion builds a local index over the Stack Exchange Archives and runs a local query using a similarity index.
2
Sep 13 '20
A friend of mine did something like this for a hack-a-thon awhile ago, but I suspect that your version is better.
1
u/da-procrastinator Sep 12 '20
I do that without that package. It just returns "first word" not found. I ask whatever I am stuck in and sometimes I swear.
0
55
u/davidmezzetti Sep 12 '20
codequestion is a Python application that enables asking coding questions directly from the terminal. Developers often have a web browser open while coding and run web searches as questions arise. codequestion attempts to make that process faster so you can focus on development.
Once a model is downloaded, codequestion does not require network connectivity and works in standalone compute environments.
codequestion is built on the txtai stack and Python 3.6+. An embeddings index is built over top Stack Exchange questions and similarity searches are executed to find the best matching question/answer for a given query.
GitHub Repo
Medium article with tech details