{"id":16981068,"url":"https://github.com/jasonacox/protosai","last_synced_at":"2025-09-06T13:32:09.388Z","repository":{"id":67236247,"uuid":"77354921","full_name":"jasonacox/ProtosAI","owner":"jasonacox","description":"A Study in Artificial Intelligence - Simple scripts that explore capabilities provided by neural networks (NN), generative pre-trained transformers (GPT) and large language models (LLM).","archived":false,"fork":false,"pushed_at":"2025-02-17T20:04:11.000Z","size":3822,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-01T16:15:54.371Z","etag":null,"topics":["artifical-intelligense","gpt","large-language-models","llama","llamacpp","llm","neural-network","sentiment-analysis","speech-recognition","summarizer","transformer"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jasonacox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2016-12-26T03:20:48.000Z","updated_at":"2025-02-23T07:24:41.000Z","dependencies_parsed_at":"2024-08-03T07:49:13.645Z","dependency_job_id":"42f3dd8a-4ce1-4a29-a86c-499df858eede","html_url":"https://github.com/jasonacox/ProtosAI","commit_stats":{"total_commits":118,"total_committers":1,"mean_commits":118.0,"dds":0.0,"last_synced_commit":"c982ef5d2eb5c48a135a19b24e885cc70bb7ba34"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jasonacox/ProtosAI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonacox%2FProtosAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonacox%2FProtosAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonacox%2FProtosAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonacox%2FProtosAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jasonacox","download_url":"https://codeload.github.com/jasonacox/ProtosAI/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonacox%2FProtosAI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273912508,"owners_count":25189969,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["artifical-intelligense","gpt","large-language-models","llama","llamacpp","llm","neural-network","sentiment-analysis","speech-recognition","summarizer","transformer"],"created_at":"2024-10-14T02:04:33.695Z","updated_at":"2025-09-06T13:32:08.697Z","avatar_url":"https://github.com/jasonacox.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ProtosAI\n\nA Study in Artificial Intelligence\n\nThis project consist of a collection of scripts that explore capabilities provided by neural networks (NN), generative pre-trained transformers (GPT) and large language models (LLM). Most of these scripts are based on models hosted by Hugging Face (https://huggingface.co/).  \n\nGoogle Colab Example: [ProtosAI.ipynb](https://colab.research.google.com/drive/1gAeHW5ViKXLWQbbm48FxKehbM0A0FI7M?usp=sharing)\n\nClasses: \n\n* Large Language Models: How do they work? ([YouTube Video](https://youtu.be/s4zEQyM_Rks?si=-0ki7cW5z2vvKEcG)) ([Notebook](gpt.ipynb))\n* Retrieval Augmented Generation (RAG) ([YouTube Video](https://youtu.be/MyCWYweJniA?si=8Vl_JwBGuGQui5U4)) ([Notebook](rag.ipynb))\n\n\n## Setup\n\nSetup required for these scripts:\n\n```bash\n# Requirements\npip install transformers datasets\npip install torch\n```\n\nNote that during the fist run, the library will download the required model to process the inputs.\n\n## Sentiment Analysis\n\nThe `sentiment.py` script prompts the user for a line of text and uses a model to determine the sentiment of the text (positive, neutral or negative).\n\n```text\nEnter some text (or empty to end): I love you.\nSentiment score: [{'label': 'positive', 'score': 0.9286843538284302}]\n\nEnter some text (or empty to end): I am sad.\nSentiment score: [{'label': 'negative', 'score': 0.7978498935699463}]\n\nEnter some text (or empty to end): I hate dirty pots.\nSentiment score: [{'label': 'negative', 'score': 0.9309694170951843}]\n\nEnter some text (or empty to end): Don't move!\nSentiment score: [{'label': 'neutral', 'score': 0.6040788292884827}]\n```\n\n## Summarization\n\nThe `summary.py` script takes a text file input and uses the summarization model to produce a single paragraph summary.\n\n```text\n$ python3 summary.py pottery.txt                                     \nLoading transformer...\n\nReading pottery.txt...\nNumber of lines: 14\nNumber of words: 566\nNumber of characters: 3416\n\nSummarizing...\nText:  The key to becoming a great artist, writer, musician, etc., is to keep creating!\nKeep drawing, keep writing, keep playing! Quality emerges from the quantity of practice\nand continuous learning that makes them more perfect . The prize of perfection comes by\ndelivering and learning, says Jason Cox .\nNumber of lines: 1\nNumber of words: 49\nNumber of characters: 299\n```\n\n## Transcribe\n\nThe `transcribe.py` script takes an audio file (mp3 or wav file) and uses a speech model to produce a basic text transcription. A additional tool `record.py` will use your laptops microphone to record your dictation into `audio.wav` that can be used by `transcribe.py`.\n\n```bash\n# Requirements - MacOS\nbrew install ffmpeg   \n\n# Requirements - Ubuntu Linux\nsudo apt install ffmpeg   \n```\n\n```text\n$ python3 transcribe.py test.wav\n\nLoading model...\n\nTranscribing test.wav...\nHELLO THIS IS A TEST\n```\n\n## Text to Speech\n\nThe `speech.py` script converts a text string into an audio file.  The script requires additional libraries:\n\n```bash\n# Requirements MacOS\nbrew install portaudio  \n\n# Requirements Ubuntu Linux\nsudo apt install portaudio19-dev\nsudo apt install python3-pyaudio\n\npip install espnet torchaudio sentencepiece pyaudio\n```\n\n```text\n$ python3 speech.py\n\nLoading models...\n\nConverting text to speech...\n\nWriting to audio.wav...\n\nSpeaking: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.\n```\n\nhttps://github.com/jasonacox/ProtosAI/assets/836718/56759007-90b6-4d94-83f2-3cc3cb78ccbe\n\n## Speech to Text\n\nThe advanced [OpenAI Whisper](https://github.com/openai/whisper) model can be used to do transcription. Sample scripts are located in the [whisper folder](https://github.com/jasonacox/ProtosAI/tree/master/whisper). \n\n* Convert MP3 audio files to Text - [transcribe-mp3.py](https://github.com/jasonacox/ProtosAI/tree/master/whisper/transcribe-mp3.py)\n* Convert YouTube videos to Text - [transcribe-youtube.py](https://github.com/jasonacox/ProtosAI/tree/master/whisper/transcribe-youtube.py)\n\n## Voice Cloning\n\nThere are several models and kits emerging that allow you to build your own speech model based on sample speech. The TTS python package is one, by coqui-ai https://github.com/coqui-ai/TTS\n\n```bash\n# Install TTS\npip install TTS\n```\n\nExample (TBD)\n\n```python\nfrom TTS.api import TTS\ntts = TTS(\"tts_models/multilingual/multi-dataset/xtts_v2\", gpu=True)\n\n# generate speech by cloning a voice using default settings\ntts.tts_to_file(text=\"It took me quite a long time to develop a voice, and now that I have it I'm not going to be silent.\",\n                file_path=\"output.wav\",\n                speaker_wav=\"/path/to/target/speaker.wav\",\n                language=\"en\")\n```\n\n## Handwriting to Text\n\nThe `handwriting.py` script converts an image of a handwritten single line of text to a string of text.\n\n```bash\n# Requirements\npip install image\n```\n\n![test.png](test.png)\n\n```text\n$ python3 handwriting.py test.png\nConverting image to text: test.png\n\nLoading transformer...\n * microsoft/trocr-base-handwritten\n\nAnalyzing handwriting from test.png...\n\nResulting text:\nThis is a test-Can you read this?\n```\n\n## Large Language Models (LLM)\n\nThe exploration of different LLMs is located in the [llm](https://github.com/jasonacox/ProtosAI/tree/master/llm) folder. The goal of this section is to explore the different LLM models, specifically related to building, training, tuning and using these models.\n\n* [BiGram](https://github.com/jasonacox/ProtosAI/tree/master/llm#bigram-model) - This experiment uses an introductory training model based on the \"Let's build a GPT from scratch\" [video](https://youtu.be/kCc8FmEb1nY?si=DHoNb1wd4nnqV5Nf) by Andrej Karpathy.\n* [nanoGPT](https://github.com/jasonacox/ProtosAI/tree/master/llm#nanogpt-model) - Similar to above but using the tiny GPT, Andrej Karpathy's [nanoGPT](https://github.com/karpathy/nanoGPT)\n* [LLaMA](https://github.com/jasonacox/ProtosAI/tree/master/llm/llama.cpp) - The [llama.cpp project's](https://github.com/ggerganov/llama.cpp) goal is to run LLaMA models using integer quantization to allow the use of these LLMs on local small scale computers like a MacBook.\n\n## OpenAI Test\n\nThe openai.py script prompts the OpenAI gpt-3.5 model and prints the response.\n\n```bash\n# Requirements\npip install openai\n\n# Test\n$ python3 gpt.py\nWhat do you want to ask? Can you say something to inspire engineers?\n\nAnswer: {\n  \"choices\": [\n    {\n      \"finish_reason\": \"stop\",\n      \"index\": 0,\n      \"message\": {\n        \"content\": \"Of course! Here's a quote to inspire engineers:\\n\\n\\\"Engineering is not only about creating solutions, it's about creating a better world. Every time you solve a problem, you make the world a little bit better.\\\" - Unknown\\n\\nAs an engineer, you have the power to make a positive impact on society through your work. Whether you're designing new technologies, improving existing systems, or solving complex problems, your contributions are essential to advancing our world. So keep pushing the boundaries of what's possible, and never forget the impact that your work can have on the world around you.\",\n        \"role\": \"assistant\"\n      }\n    }\n  ],\n  \"created\": 1685856679,\n  \"id\": \"chatcmpl-7Nach0z2sJQ5FzZOVl6jZWPU4O6zV\",\n  \"model\": \"gpt-3.5-turbo-0301\",\n  \"object\": \"chat.completion\",\n  \"usage\": {\n    \"completion_tokens\": 117,\n    \"prompt_tokens\": 26,\n    \"total_tokens\": 143\n  }\n}\n```\n\n## GPT-2 Text Generation\n\nThe `gpt-2.py` script uses the gpt2-xl model to generate test based on a prompt.\n\n```bash\n$ python3 gpt-2.py   \n```\n\n```json\n[{'generated_text': \"Hello, I'm a language model, but what I do you need to know isn't that hard. But if you want to understand us, you\"}, {'generated_text': \"Hello, I'm a language model, this is my first commit and I'd like to get some feedback to see if I understand this commit.\\n\"}, {'generated_text': \"Hello, I'm a language model, and I'll guide you on your journey!\\n\\nLet's get to it.\\n\\nBefore we start\"}, {'generated_text': 'Hello, I\\'m a language model, not a developer.\" If everything you\\'re learning about code is through books, you\\'ll never get to know about'}, {'generated_text': 'Hello, I\\'m a language model, please tell me what you think!\" – I started out on this track, and now I am doing a lot'}]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonacox%2Fprotosai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjasonacox%2Fprotosai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonacox%2Fprotosai/lists"}