Skip to main content

GraphSense

GraphSense is a framework that can be used to easily train and use code suggestion models with minimal data preprocessing and resource consumption. No transformers are used and underlying algorithm used was Node2Vec. FAISS used as the vector index and RocksDB used to store code line to index and index to code line mappings.

GraphSense is highly optimized for performance and efficiency.

Requirements

  • Python 3.8 or greater

installation:

pip install graphsense

Training example:

from graphsense import GraphTrain

g = GraphTrain()
# train the model
g.line_completion(directory_path="code_files", language="Python")

Inference example:

from graphsense import GraphInfer

g = GraphInfer()

g.load_artifacts()  # load the artifacts to memory
suggestions = g.infer("def factorial(n):")
g.unload_artifacts()  # clean memory

print("top 10 suggestions: ", suggestions)

Performance Comparison with gpt2_medium finetuned model

Dataset used to train models: https://github.com/TheAlgorithms/Python

gpt2-medium model (Fine-tuned on Python Algorithms dataset)

artifacts size: 1.44 GB   
avg inference time (CPU): 8 seconds 
avg inference time (GPU): 2.2662 seconds
avg memory usage: 1800 MB 

GraphSense (trained on Python Algorithms dataset)

artifacts size: 13.9 MB
avg inference time (CPU): 0.0079 seconds 
avg memory usage: 277.8194 MB 

Performance and Scalability

Accuracy of GraphSense (vector size: 128)

Dataset Top-1 Accuracy Top-3 Accuracy Top-10 Accuracy
TheAlgorithms(Python) 0.4718 0.8012 0.8958

Scalability of GraphSense (CPU) (vector size: 128)

vocabulary = 100,000
average memory usage: 273.777 MB
average execution time: 0.0113 seconds
artifacts size: 61.3 MB

vocabulary = 200,000
average memory usage: 325.8949 MB
average execution time: 0.0155 seconds
artifacts size: 122 MB

vocabulary = 300,000
average memory usage: 377.1085 MB
average execution time: 0.0185 seconds
artifacts size: 168 MB

vocabulary = 400,000
average memory usage: 428.3011 MB
average execution time: 0.0227 seconds
artifacts size: 224 MB

vocabulary = 500,000
average memory usage: 478.8532 MB
average execution time: 0.0273 seconds
artifacts size: 280 MB

vocabulary = 600,000
average memory usage: 531.0189 MB
average execution time: 0.0301 seconds
artifacts size: 368 MB

vocabulary = 700,000
average memory usage: 581.3494 MB
average execution time: 0.0333 seconds
artifacts size: 429 MB

vocabulary = 800,000
average memory usage: 633.226 MB
average execution time: 0.038 seconds
artifacts size: 448 MB

vocabulary = 900,000
average memory usage: 685.1932 MB
average execution time: 0.0439 seconds
artifacts size: 552 MB

vocabulary = 1,000,000
average memory usage: 734.5819 MB
average execution time: 0.0444 seconds
artifacts size: 561 MB

Metadata

Release files for graphsense 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for graphsense 0.0.3
File Size Uploaded Provenance Actions
graphsense-0.0.3.tar.gz 9.1 kB Without provenance Details for graphsense-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for graphsense 0.0.3
File Interpreter ABI Platform Actions
graphsense-0.0.3-py3-none-any.whl Python 3 none any Details for graphsense-0.0.3-py3-none-any.whl

Total release size: 17.6 kB

Release files / graphsense-0.0.3.tar.gz

Download URL graphsense-0.0.3.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6ae103bbfb2d7cdca75475afd6f4f757f5953f5e82d013f7be7bccbdda97a65e
BLAKE2b-256 checksum
How to use checksums
ed5ffbe75754ee8b95f33b53d13291ca93106377a4f21e9ff062191c9ed7bb84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.8

Release files / graphsense-0.0.3-py3-none-any.whl

Download URL graphsense-0.0.3-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57a5678a6f40ade004f90b9e258e0f5e5e910f880f48af48fdd8b8ac1af6fa08
BLAKE2b-256 checksum
How to use checksums
07372969379db998a3fac7877035fa19a47825ca50ac07381362c754fbeb8719
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.8

Security for graphsense 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page