sentence-transformers How to use Shuu12121/CodeSearch-ModernBERT-Owl-ph2 with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("Shuu12121/CodeSearch-ModernBERT-Owl-ph2")
sentences = [
"Disconnects the pool.\n\nDoes everything that +clear+ does, except if the pool is closed\nthis method does nothing but +clear+ would raise PoolClosedError.\n\n@since 2.1.0\n@api private",
"def disconnect!(options = nil)\n do_clear(options)\n rescue Error::PoolClosedError\n # The \"disconnected\" state is between closed and paused.\n # When we are trying to disconnect the pool, permit the pool to be\n # already closed.\n end",
"func TestNamedTupleWithEscapedColumns(t *testing.T) {\n\tTestProtocols(t, func(t *testing.T, protocol clickhouse.Protocol) {\n\t\tconn, err := GetNativeConnection(t, protocol, nil, nil, nil)\n\t\tctx := context.Background()\n\t\trequire.NoError(t, err)\n\t\t// https://github.com/ClickHouse/ClickHouse/pull/36544\n\t\tif !CheckMinServerServerVersion(conn, 22, 5, 0) {\n\t\t\tt.Skip(fmt.Errorf(\"unsupported clickhouse version\"))\n\t\t\treturn\n\t\t}\n\t\tconst ddl = \"CREATE TABLE test_tuple (Col1 Tuple(`56` String, `a22\\\\`` Int64)) Engine MergeTree() ORDER BY tuple()\"\n\t\tdefer func() {\n\t\t\tconn.Exec(ctx, \"DROP TABLE IF EXISTS test_tuple\")\n\t\t}()\n\t\trequire.NoError(t, conn.Exec(ctx, ddl))\n\t\tbatch, err := conn.PrepareBatch(ctx, \"INSERT INTO test_tuple\")\n\t\trequire.NoError(t, err)\n\t\tvar (\n\t\t\tcol1Data = map[string]any{\"56\": \"A\", \"a22`\": int64(1)}\n\t\t)\n\t\trequire.NoError(t, batch.Append(col1Data))\n\t\trequire.Equal(t, 1, batch.Rows())\n\t\trequire.NoError(t, batch.Send())\n\t\tvar col1 map[string]any\n\t\trequire.NoError(t, conn.QueryRow(ctx, \"SELECT * FROM test_tuple\").Scan(&col1))\n\t\tassert.Equal(t, col1Data, col1)\n\t})\n}",
"def parse_region(url)\n parts = URI.parse(url).host.split('.')\n parts.each_with_index do |part, index|\n if part == 'sqs'\n # assume region is the part right after the 'sqs' part\n return parts[index + 1]\n end\n end\n nil # no region found\n end"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]