Skip to content

Instantly share code, notes, and snippets.

@iamaziz
iamaziz / ollachat_ar.py
Last active April 4, 2025 14:09
Ollama UI for Arabic (right-to-left) based on: https://github.com/iamaziz/ollachat (example in the comments)
import os
import json
import datetime
import streamlit as st
from llama_index.llms import Ollama
from llama_index.llms import ChatMessage
# https://docs.llamaindex.ai/en/stable/examples/llm/ollama.html
@iamaziz
iamaziz / LLM-from-scratch.ipynb
Created July 23, 2023 17:02
Building a large language model (LLM) from scratch (for learning and fun - inspired by Llama2).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iamaziz
iamaziz / vector_search-vs-semantic_reranker.ipynb
Created January 15, 2025 06:17
RAG: vector search vs. semantic reranker
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iamaziz
iamaziz / code_completion_ide.py
Last active January 12, 2025 13:22
simple offline code completion example with ollama/streamlit and code execution
import sys
from io import StringIO
import streamlit as st # pip install streamlit
from code_editor import code_editor # pip install streamlit_code_editor
import ollama as ol # pip install ollama
st.set_page_config(layout='wide')
st.title('`Offline code completion`')
@iamaziz
iamaziz / entropy_gain.py
Last active November 1, 2024 13:45
Calculate Entropy and Information Gain for Decision Tree Learning
# -*- coding: utf-8 -*-
# calculating the Entropy and Information Gain for: Learning with Trees
# by: Aziz Alto
# see Information Gain:
# http://www.autonlab.org/tutorials/infogain.html
from __future__ import division
@iamaziz
iamaziz / mlp-mini.py
Last active October 10, 2024 12:04
Multi-Layer Perceptron in Theano (minimal example)
>>> # Multi-layer perceptron in Theano see: http://ir.hit.edu.cn/~jguo/docs/notes/a_simple_tutorial_on_theano.pdf
>>> import numpy
>>> import theano
>>> import theano.tensor as T
>>> rng = numpy.random
>>> N = 400
>>> feats = 784
>>> D = (rng.randn(N, feats), rng.randint(size=N, low=0,high=2) )
>>> training_steps = 10000
>>> x = T.matrix('x')
@iamaziz
iamaziz / df2fhtml.py
Created August 24, 2024 15:11
Convert pd.dataframe df to FastHTML table. Similar to `df.to_html()` but different
from fasthtml import common as fh
def df2fhtml(df: pd.DataFrame, with_headers: bool=True, **kwargs):
cols = df.columns
header = fh.Tr(*[fh.Th(fh.Label(col)) for col in cols])
rows = [fh.Tr(*[fh.Td(df[col][i]) for col in cols]) for i in range(len(df))]
return fh.Table(header if with_headers else '', *rows, **kwargs)
@iamaziz
iamaziz / dspy_ollama_getting_started.ipynb
Last active July 30, 2024 15:01
Getting started with DSPy and Ollama
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iamaziz
iamaziz / fast_speech_text_speech_steramlit_app.py
Last active May 28, 2024 08:08 — forked from thomwolf/fast_speech_text_speech.py
speech to text to speech (Srteamlit App) - example in the comments
""" To use: install Ollama (or LLM studio), clone OpenVoice, run this script in the OpenVoice directory
git clone https://github.com/myshell-ai/OpenVoice
cd OpenVoice
git clone https://huggingface.co/myshell-ai/OpenVoice
cp -r OpenVoice/* .
pip install whisper pynput pyaudio streamlit ollama
script source: https://x.com/Thom_Wolf/status/1758140066285658351?s=20
"""
@iamaziz
iamaziz / Jais-LLM-GettingStarted-v2.ipynb
Last active April 16, 2024 16:59
Running Jais LLM on M3 Max chip with 64GB - using `torch_dtype=torch.float16`. Now much faster but way off
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.