Skip to content

Instantly share code, notes, and snippets.

View zachschillaci27's full-sized avatar

Zach Schillaci zachschillaci27

View GitHub Profile
@zachschillaci27
zachschillaci27 / spacy_get_most_similar_word.py
Created August 31, 2022 15:19
Get the most similar word in a spaCy model vocabulary based on word vector distance
import numpy as np
import spacy
from spacy.language import Language
from typing import Callable
def get_most_similar_word(nlp: spacy.language.Language, word: str, metric: Callable[[np.array, np.array], float]) -> str:
# Get the vector of representation of the query word
vector = nlp.vocab.get_vector(word)
# Get the most similar vector by row index in the word vector matrix
@zachschillaci27
zachschillaci27 / extract_hyperlinks_from_excel.py
Last active November 6, 2024 11:05
Extract URLs from hyperlinks in Excel using openpyxl and pandas
@zachschillaci27
zachschillaci27 / llama-2-setup.md
Last active April 13, 2025 12:22
Download and run llama-2 locally

Option 1 (easy): HuggingFace Hub Download

  1. Request access to one of the llama2 model repositories from Meta's HuggingFace organization, for example the Llama-2-13b-chat-hf.
  2. Generate a HuggingFace read-only access token from your user profile settings page.
  3. Setup a Python 3.10 enviornment with the following dependencies installed: transformers, huggingface_hub.
  4. Run the following code to download and load the model in HuggingFace transformers:
TOKEN = # copy-paste your HuggingFace access token here

### Option 1
@zachschillaci27
zachschillaci27 / graph.viz
Created November 29, 2023 16:05
Decision tree for building a custom LLM solution
digraph G {
graph [fontname = "Handlee"];
node [fontname = "Handlee"];
edge [fontname = "Handlee"];
bgcolor=transparent;
subgraph cluster_0 {
color=orange;
label="Usage"
@zachschillaci27
zachschillaci27 / dummy_function_call.py
Created December 7, 2023 18:04
OpenAI API: Generate dummy function call for testing
import json
from typing import Any, Type
from pydantic import BaseModel
class FunctionSchemaForOpenAI(BaseModel):
name: str
description: str
func_schema: Type[BaseModel]