Skip to content

Instantly share code, notes, and snippets.

View bsod90's full-sized avatar

Maxim bsod90

  • cube.dev
  • California
View GitHub Profile
# Connect to the semantic-search service and run the query
con = get_victor_connection()
response = con.FindTopKProblems(
victor_pb2.TopKProblemsRequest(
query=search_query,
# In our implementation -1 means "return all matches"
k=-1,
),
)
FROM python:3.6
RUN apt-get update -y
RUN apt-get install -y unzip wget
RUN apt-get install -y default-jdk
RUN wget http://h2o-release.s3.amazonaws.com/h2o/rel-wolpert/8/h2o-3.18.0.8.zip
RUN unzip ./h2o-3.18.0.8.zip
RUN mv h2o-3.18.0.8/h2o.jar /tmp/
import tensorflow as tf
import tensorflow_hub as hub
from tensorflow.saved_model import simple_save
export_dir = "./models/use/00000001"
with tf.Session(graph=tf.Graph()) as sess:
module = hub.Module("https://tfhub.dev/google/universal-sentence-encoder-multilingual-large/1")
text_input = tf.placeholder(dtype=tf.string, shape=[None])
sess.run([tf.global_variables_initializer(), tf.tables_initializer()])
state_dir = './search_data/'
faiss.write_index(
index,
os.path.join(state_dir, "faiss.index")
)
index = faiss.read_index(
os.path.join(state_dir, "faiss.index")
)
import faiss
from encoder import UniversalEncoder
# Don't forget to start the encoder container locally and open the 8501 port
encoder = UniversalEncoder(host='localhost', port=8501)
data = [
'What color is chameleon?',
'When is the festival of colors?',
'When is the next music festival?',
syntax = "proto3";
message TopKDocumentsRequest {
string query = 1;
int32 k = 2;
}
message DocumentsWithinDistanceRequest {
string query = 1;
double distance = 2;
@bsod90
bsod90 / encoder.py
Last active August 3, 2019 03:57
Sample encoder interface and Universal Sentence Encoder client
import logging
from abc import ABC, abstractmethod
from typing import Iterable, List
import requests
import numpy as np
logger = logging.getLogger(__name__)
@bsod90
bsod90 / .tmux.conf
Last active July 9, 2018 22:29
Tmux config
# A status line theme generated by tmuxline.vim
if-shell "test -f ~/.tmuxline" "source ~/.tmuxline"
set -g default-terminal "screen-256color"
# Enables a true-color support in Tmux
set-option -ga terminal-overrides ",xterm-256color:Tc"
# Moving between panes.
bind h select-pane -L
bind j select-pane -D
@bsod90
bsod90 / .zshrc
Last active July 9, 2018 21:25
Extra stuff in .zshrc
# I really like this minimalistic zsh theme.
export ZSH_THEME="refined"
# This is important if you'd like to use TrueColor themes in Neovim
export NVIM_TUI_ENABLE_TRUE_COLOR=1
# This makes Neovim your default editor
export VISUAL=nvim
export EDITOR="$VISUAL"
@bsod90
bsod90 / init.vim
Created July 3, 2018 08:11
My vim config
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.local/share/nvim/plugged')
" Make sure you use single quotes
" Airline is a plugin that makes the status line look fancier.
" It requires a custom font (with arrows), and is completely optional
Plug 'vim-airline/vim-airline'