Skip to content

Instantly share code, notes, and snippets.

@srcecde
srcecde / reciprocal_rank_fusion_impl.py
Created December 18, 2023 21:45
Reciprocal Rank Fusion implementation
from collections import defaultdict
def reciprocal_rank_fusion(*list_of_list_ranks_system, K=60):
"""
Fuse rank from multiple IR systems using Reciprocal Rank Fusion.
Args:
* list_of_list_ranks_system: Ranked results from different IR system.
K (int): A constant used in the RRF formula (default is 60).
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "execute-api:/*/*/*"
},
{
AWSTemplateFormatVersion : "2010-09-09"
Description: "Sample Template"
Parameters:
S3BucketName:
Description: Enter S3 bucket name
Type: String
MinLength: 3
MaxLength: 10
AllowedPattern: "^[A-Za-z0-9_-]*$"
AWSTemplateFormatVersion: "2010-09-09"
Description: "Create EC2 instance | FindInMap"
Parameters:
Environment:
Type: String
AllowedValues:
- dev
- prod
- qa
import os
import json
import boto3
def lambda_handler(event, context):
if event:
messages_to_reprocess = []
batch_failure_response = {}
for record in event["Records"]:
try:
import os
import json
import boto3
def lambda_handler(event, context):
region_name = os.environ['AWS_REGION']
if event:
sqs = boto3.resource('sqs', region_name=region_name)
queue_name = event['Records'][0]['eventSourceARN'].split(':')[-1]
queue = sqs.get_queue_by_name(QueueName=queue_name)
import os
import json
import boto3
def lambda_handler(event, context):
region_name = os.environ['AWS_REGION']
if event:
sqs = boto3.client('sqs', region_name=region_name)
queue_name = event['Records'][0]['eventSourceARN'].split(':')[-1]
queue_url = sqs.get_queue_url(
import json
import boto3
def lambda_handler(event, context):
region_name = os.environ['AWS_REGION']
if event:
for record in event['Records']:
body = record['body']
# process message
return {
@srcecde
srcecde / Install ffmpeg & ffprobe on Amazon Linux
Created November 19, 2021 08:19
Install & configure ffmpeg, ffprobe on SageMaker (Amazon Linux)
cd /usr/local/bin
sudo mkdir ffmpeg && cd ffmpeg
# check https://johnvansickle.com/ffmpeg/ for latest build
sudo wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
sudo tar -xf ffmpeg-release-amd64-static.tar.xz
sudo ln -s /usr/local/bin/ffmpeg/ffmpeg-4.4.1-amd64-static/ffmpeg /usr/bin/ffmpeg
sudo ln -s /usr/local/bin/ffmpeg/ffmpeg-4.4.1-amd64-static/ffprobe /usr/bin/ffprobe
from manimlib.scene.scene import Scene
from manimlib.mobject.matrix import Matrix
from manimlib import *
class manim_mobject_matrix_001a(Scene):
def construct(self):
sans = 'monospace'
size = 0.5
play_kw = {"run_time": 0.5}