Noa Nabeshima
import torch
import numpy as np
from manifoldpy import api
from sentence_transformers import SentenceTransformer
markets = api.get_all_markets()
questions = [market.question for market in markets]
model = SentenceTransformer('all-MiniLM-L6-v2')
embeddings = model.encode(questions)
query_embed = model.encode(question)
question = 'Will there be a debt ceiling showdown before 2025?'
sims = embeddings @ query_embed
relevant_markets = np.array(markets)[torch.tensor(sims).topk(k=10).indices]
this works pretty well, though you'd probably want to cache the embeddings somehow (takes 41s on my computer)