Skip to content

Instantly share code, notes, and snippets.

View NirantK's full-sized avatar

Nirant NirantK

View GitHub Profile
@NirantK
NirantK / qrel_validation.py
Created April 29, 2024 12:14
Validation function for Qrels. Helpful for working with TREC Tools
def validate_data(predictions, references):
# Define expected fields and types for predictions and references
expected_pred_keys = {
'query': int, 'q0': str, 'docid': str, 'rank': int, 'score': float, 'system': str
}
expected_ref_keys = {
'query': int, 'q0': str, 'docid': str, 'rel': int
}
@NirantK
NirantK / snippets.py
Created April 9, 2024 04:47
Qdrant Python for Hybrid Search
## Recommended Imports
from qdrant_client import QdrantClient
from qdrant_client.models import (
Distance,
NamedSparseVector,
NamedVector,
SparseVector,
PointStruct,
SearchRequest,
SparseIndexParams,
@NirantK
NirantK / splade-single-encoder.ipynb
Last active March 12, 2024 20:25
splade-single-encoder.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@NirantK
NirantK / splade-demo.ipynb
Created December 4, 2023 13:14
SPLADE-Demo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import codecs
import functools
import heapq
import io
import mimetypes
import operator
import random
import re
import subprocess
import tempfile
@NirantK
NirantK / DataSciencePMInterview.md
Last active April 6, 2022 17:07
ML PM Interview Notes Written for Swanand on 2022-04-06
  • Focus Areas
    • Metrics
      • Ability to understand how does a machine learning model performance tie back to product performance e.g. does reducing ML error improve NPS? Retention?
    • Errors
      • Candidate should be able to navigate a confusion matrix, without being confused
    • Experimentation
      • Most PMs coming from the feature/problem solving nature of the universe are often fumbling around when they realise that experiments have high failure rate — even after everything worked on your local tests
      • The ask here is not for patience, but for the ability of the PM to call out/rank different errors. Here is an incomplete example:
        • Credit card fraud: Is it okay if you blocked emergency medical payment while on travel?
  • Payments in new geographies often get blocked
@NirantK
NirantK / gopath
Last active September 9, 2019 08:01 — forked from austingebauer/gopath
Set GOPATH, GOBIN, and PATH in current directory
#!/usr/bin/env bash
#
# Sets the GOPATH and GOBIN to the current directory.
# Adds GOBIN to the PATH.
#
# Usage:
# 1. Put this script somewhere on your PATH.
# 2. Enter directory of a golang project (contains src, pkg, bin)
# 3. Execute: . gopath
@NirantK
NirantK / f-strings-demo-6.py
Last active July 4, 2023 10:54
lambda functions in f strings
# If you feel you must use lambdas, they may be used inside of parentheses:
print(f'{(lambda x: x*3)(3)}')
# '9'
# not that this returned a <str> and not <int>
@NirantK
NirantK / f-strings-demo-5.py
Created April 16, 2018 11:59
fstring expression eval demo
items = list(range(0, 5)) # create list of 5 elements
print(items)
# [0, 1, 2, 3, 4]
print(f'number of items: {len(items)}')
# number of items: 5
@NirantK
NirantK / f-string-demo-4.py
Last active August 28, 2020 07:57
f string Spacing Demo
correct = 'correct'
phonetic_correct = 'phonetic_correct'
typo = 'typo'
phonetic_typo = 'phonetic_typo'
phonetic_distance = 'phonetic_distance'
print(f'No Spacing:')
print(f'{correct}|{phonetic_correct}|{typo}|{phonetic_typo}|{phonetic_distance}|\n')
# No Spacing:
# correct|phonetic_correct|typo|phonetic_typo|phonetic_distance|