Skip to content

Instantly share code, notes, and snippets.

View rohitgarud's full-sized avatar
💭
Stop wasting time and 'GIT' it done

Rohit Garud rohitgarud

💭
Stop wasting time and 'GIT' it done
View GitHub Profile
@rohitgarud
rohitgarud / simulate_cosinesim.py
Last active March 10, 2023 04:02
Gist for calculating cosine similarity between resultants of different groups of feature vectors (ASReview screening)
from pathlib import Path
import matplotlib.pyplot as plt
import pandas as pd
from asreview import ASReviewData, ASReviewProject, open_state
from asreview.models.balance import DoubleBalance
from asreview.models.classifiers import NaiveBayesClassifier
from asreview.models.feature_extraction import Tfidf
from asreview.models.query import MaxQuery
from asreview.review import ReviewSimulate
@rohitgarud
rohitgarud / bm25.py
Created March 17, 2023 09:37 — forked from koreyou/bm25.py
Implementation of OKapi BM25 with sklearn's TfidfVectorizer
""" Implementation of OKapi BM25 with sklearn's TfidfVectorizer
Distributed as CC-0 (https://creativecommons.org/publicdomain/zero/1.0/)
"""
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
from scipy import sparse
class BM25(object):
@rohitgarud
rohitgarud / document-embeddings-big_models.ipynb
Created March 21, 2023 12:38 — forked from lmcinnes/document-embeddings-big_models.ipynb
Document Embeddings with Vectorizers and Large USE and BERT models
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rohitgarud
rohitgarud / order_model.py
Last active January 12, 2025 13:58
Transform JSON schema from Pydantic model_json_schema() into something simpler for LLM to understand
from enum import Enum
from typing import List, Optional
from datetime import datetime
from pydantic import (
BaseModel,
EmailStr,
Field,
HttpUrl
)
@rohitgarud
rohitgarud / dspy_custom_adapters.py
Last active December 9, 2024 09:14
Custom JSON Adapter for DSPy which uses ProcessSchema to simplify the JSON schema injected in the prompt when InputField or OutputField of the signature has Pydantic model as a type
import enum
import inspect
import json
import re
import textwrap
from typing import Any, Dict, Literal
import json_repair
import pydantic
from dspy.adapters.image_utils import Image