Hugging Face's logo Hugging Face
  • Models
  • Datasets
  • Spaces
  • Buckets new
  • Docs
  • Enterprise
  • Pricing

  • Log In
  • Sign Up

Nan-Do
/
CP-Ranker

Sentence Similarity
sentence-transformers
Safetensors
new
feature-extraction
dense
Generated from Trainer
dataset_size:865218
loss:TripletLoss
custom_code
text-embeddings-inference
Model card Files Files and versions
xet
Community

Instructions to use Nan-Do/CP-Ranker with libraries, inference providers, notebooks, and local apps. Follow these links to get started.

  • Libraries
  • sentence-transformers

    How to use Nan-Do/CP-Ranker with sentence-transformers:

    from sentence_transformers import SentenceTransformer
    
    model = SentenceTransformer("Nan-Do/CP-Ranker", trust_remote_code=True)
    
    sentences = [
        "Swaps in a String\nYou are given a string $S$ that contains of the characters $A$, $B$ or $C$ only.\n\nIn one operation, you can do either of the following:\n\n- Choose an occurrence of $\\text{AB}$ in the string, convert it to $\\text{BA}$.\n- Choose an occurrence of $\\text{BC}$ in the string, convert it to $\\text{CB}$.\n\nNote that you are only allowed to operate on adjacent elements.\n\nFind the maximum number of operations you can do. It can be proven the answer is finite.\n\nInput Format:\n- The first line of input will contain a single integer $T$, denoting the number of test cases.\n- Each test case consists of multiple lines of input.\n    - The first line of each test case contains $N$ - the length of the string.\n    - The second line contains $S$ - the string.\n\nOutput Format:\nFor each test case, output on a new line the maximum number of operations possible.\n\nConstraints:\n- $1 \\le T \\le 10^4$\n- $2 \\le N \\le 2 \\cdot 10^5$\n- $|S| = N$\n- $S_i \\in \\{A, B, C\\}$\n- The sum of $N$ over all test cases does not exceed $2 \\cdot 10^5$.\n\nSample 1:\nInput:\n3\n4\nABCC\n5\nBAABB\n2\nBA\n\nOutput:\n2\n4\n0\nExplanation:\n**Test Case 1** : We can convert $\\text{ABCC}$ to $\\text{ACBC}$ and then to $\\text{ACCB}$. More than $2$ operations can be proven to be impossible.\n\n**Test Case 2** : $\\text{BAABB} \\rightarrow \\text{BABAB} \\rightarrow \\text{BBAAB} \\rightarrow \\text{BBABA} \\rightarrow \\text{BBBAA}$.\n",
        "#from collections import Counter\r\n#import math\r\n#import deque\r\nt=int(input())\r\nfor _ in range(t):\r\n    n=int(input())\r\n    a=input()\r\n    C1=[]\r\n    C2=[]\r\n    c1=0\r\n    c2=0\r\n    res=0\r\n    for i in a:\r\n        if i=='A':\r\n            c1+=1\r\n        elif i=='B':\r\n            pass\r\n        else:\r\n            c1=0\r\n        C1.append(c1)\r\n    for i in a[::-1]:\r\n        if i=='A':\r\n            c2=0\r\n        elif i=='B':\r\n            pass\r\n        else:\r\n            c2+=1\r\n        C2.append(c2)\r\n    C2=C2[::-1]\r\n    for i in range(n):\r\n        if a[i]=='B':\r\n            res+=max(C1[i],C2[i])\r\n    print(res)",
        "#from collections import Counter\r\n#import math\r\n#import deque\r\nt=int(input())\r\nfor _ in range(t):\r\n    n=int(input())\r\n    a=input()\r\n    C1=[]\r\n    C2=[]\r\n    c1=0\r\n    c2=0\r\n    res=0\r\n    for i in a:\r\n        if i=='A':\r\n            c1+=1\r\n        elif i=='C':\r\n            c1=0\r\n        C1.append(c1)\r\n    for i in a[::-1]:\r\n        if i=='A':\r\n            c2=0\r\n        elif i=='C':\r\n            c2+=1\r\n        C2.append(c2)\r\n    C2=C2[::-1]\r\n    for i in range(n):\r\n        if a[i]=='B':\r\n            res+=max(C1[i],C2[i])\r\n    print(res)",
        "# cook your dish here\r\nimport math\r\nfor _ in range(int(input())):\r\n    n=int(input())\r\n    x=math.ceil(n/2)\r\n    y=math.ceil(n/3)\r\n    print(x,y)\r\n    "
    ]
    embeddings = model.encode(sentences)
    
    similarities = model.similarity(embeddings, embeddings)
    print(similarities.shape)
    # [4, 4]
  • Notebooks
  • Google Colab
  • Kaggle
CP-Ranker
1.74 GB
Ctrl+K
Ctrl+K
  • 1 contributor
History: 2 commits
Nan-Do's picture
Nan-Do
Initial commit
277d2ee verified 6 months ago
  • 1_Pooling
    Initial commit 6 months ago
  • .gitattributes
    1.52 kB
    initial commit 6 months ago
  • README.md
    324 kB
    Initial commit 6 months ago
  • config.json
    1.4 kB
    Initial commit 6 months ago
  • config_sentence_transformers.json
    283 Bytes
    Initial commit 6 months ago
  • configuration.py
    7.13 kB
    Initial commit 6 months ago
  • model.safetensors
    1.74 GB
    xet
    Initial commit 6 months ago
  • modeling.py
    59 kB
    Initial commit 6 months ago
  • modules.json
    229 Bytes
    Initial commit 6 months ago
  • sentence_bert_config.json
    58 Bytes
    Initial commit 6 months ago
  • special_tokens_map.json
    833 Bytes
    Initial commit 6 months ago
  • tokenizer.json
    712 kB
    Initial commit 6 months ago
  • tokenizer_config.json
    1.44 kB
    Initial commit 6 months ago
  • vocab.txt
    232 kB
    Initial commit 6 months ago