This project is designed to be opened in GitHub Codespaces as an easy way for anyone to try out SLMs (small language models) entirely in the browser.
-
Open the Codespace in the browser using the
Code
button at the top of the repository. -
Once the Codespace is loaded, it should have ollama pre-installed as well as the OpenAI Python SDK.
-
Ask Ollama to run the SLM of your choice. For example, to run the phi3 model:
ollama run phi3:mini
That will take a few minutes to download the model into the Codespace.
-
Once you see "success" in the output, you can send a message to that model from the prompt.
>>> Write a haiku about hungry hippos
-
After several seconds, you should see a response stream in from the model.
-
To learn about different techniques used with language models, open the Python notebook
ollama.ipynb
and run each cell . If you used a model other than 'phi3:mini', change theMODEL_NAME
in the first cell. -
To have a conversation with a model from Python, open the Python file
chat_history.py
and run it. You can change theMODEL_NAME
at the top of the file as needed, and you can also modify the system message or add few-shot examples if desired.
For more information about working with the Phi-3 model, check out the Phi-3 Cookbook.
To learn more about generative AI generally, check out Generative AI for beginners.
For example code that works with OpenAI models as well, try python-openai-demos.