buelfhood/SOCO_TRAIN_java
Viewer • Updated • 76.5k • 35
How to use buelfhood/SOCO-Java-codeberta-cmnrl-triplets-ep1-bs256-lr5e-05-split0.2 with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("buelfhood/SOCO-Java-codeberta-cmnrl-triplets-ep1-bs256-lr5e-05-split0.2")
sentences = [
"import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass BruteForce {\n\n String password=\"\";\n\n int num =401;\n\n\n public static void main (String[] args) {\n\n String str=\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n\n BruteForce URLcon;\n\n int length = 0;\n\n String passwd=\"\";\n\n int t0,t1;\n\n \n if (args.length == 0) {\n \t\n \tSystem.err.println (\n \t\t\n \t\t\"Usage : java BruteForce <username>\");\n \treturn;\n \t\n \t}\n String username = args[0];\n \n\n t0=System.currentTimeMillis();\n\n System.out.println (\" \" + new Date());\n \n System.out.println (\"Using BruteForce method attack \"+username+\"'s password.Please waiting.......\");\n\n for (int i=0;i<str.length();i++){\n\n passwd=str.substring(i,i+1);\n\n URLcon = new BruteForce (passwd,username);\n\n if ((URLcon.num)!=401) {\n\n \tt1=System.currentTimeMillis();\n\n System.out.println(\"The password: \"+ passwd);\n\n \tdouble dt =t1-t0;\n\n\n\n \tSystem.out.println(\"It took \"+ DecimalFormat.getInstance().format(dt/1000)+ \" seconds.\");\n\n System.out.println (\"Finish \" + new Date());\n \n \treturn;\n\n }\n\n for (int j=0;j<str.length();j++){\n\n passwd =str.substring(i,i+1)+str.substring(j,j+1);\n\n URLcon = new BruteForce (passwd,username);\n\n if ((URLcon.num)!=401) {\n\n \t t1=System.currentTimeMillis();\n\n System.out.println(\"The password: \"+ passwd);\n\n\n double dt =t1-t0;\n\n\n\n System.out.println(\"It took \"+ DecimalFormat.getInstance().format(dt/1000)+ \" seconds.\");\n System.out.println (\"Finish \" + new Date());\n \t return;\n\n }\n for (int m=0;m<str.length();m++){\n\n passwd = str.substring(i,i+1)+str.substring(j,j+1)+str.substring(m,m+1);\n\n URLcon = new BruteForce (passwd,username);\n\n if ((URLcon.num)!=401) {\n\n \tt1=System.currentTimeMillis();\n\n System.out.println(\"The password: \"+ passwd);\n\n\n \t double dt =t1-t0;\n\n\n\n \tSystem.out.println(\"It took \"+DecimalFormat.getInstance().format(dt/1000)+ \" seconds.\");\n \n System.out.println (\"Finish \" + new Date());\n \n \t return;\n\n }\n\n\n }\n\n}\n}\n System.out.println(\" not find the password\");\n\n}\n\n public BruteForce (String password, String username){\n\n \t String urlString = \"http://sec-crack.cs.rmit.edu./SEC/2/\" ;\n\n \n\n try {\n\n String userPassword = username+\":\"+password ;\n\n String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n URL url = new URL (urlString);\n\n HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n uc.setRequestProperty (\"Authorization\", \" \" + encoding);\n\n url = uc.getResponseCode();\n\n\n }\n catch(MalformedURLException e){\n \t System.out.println(e);\n }catch(IOException e){\n System.out.println(e);\n }\n\n\n }\n}",
"import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n private String password=\"\";\n\n private int num=401;\n\n\n public static void main(String[] args) {\n\n\n Dictionary URLcon;\n\n int length = 0;\n\n String passwd=\"\";\n\n int t0,t1;\n\n String line =\"\";\n \n if (args.length == 0) {\n \t\n System.err.println (\n \t\t\n \t\t\"Usage : java BruteForce <username>\");\n return;\n \t\n }\n \n String username = args[0];\n \n \n t0=System.currentTimeMillis();\n \n System.out.println (\" \" + new Date());\n System.out.println (\"Using Dictionary method attack \"+username+\"'s password. Please waiting.......\");\n\n try{ BufferedReader in = new BufferedReader(new FileReader(\"/usr/share/lib/dict/words\"));\n\n while ((passwd=in.readLine())!=null) {\n\n \t URLcon = new Dictionary (passwd,username);\n\n if ((URLcon.num)!=401) {\n\n \tt1=System.currentTimeMillis();\n\n System.out.println(\"The password: \"+ passwd);\n\n \tdouble dt =t1-t0;\n\n \tSystem.out.println(\"It took \"+DecimalFormat.getInstance().format(dt/1000)+ \" seconds\");\n \n System.out.println (\"Finish \" + new Date());\n \n \treturn;\n\n }\n\n\n \t}\n\n }catch (FileNotFoundException e){\n \tSystem.out.println(e);\n }catch (IOException e){\n \tSystem.out.println(e);\n }\n\n\n System.out.println(\" not find the password\");\n\n\n}\n\n public Dictionary (String password,String username) {\n\n \t String urlString = \"http://sec-crack.cs.rmit.edu./SEC/2/\" ;\n\n \n try {\n\n String userPassword = username+\":\"+password ;\n\n String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n URL url = new URL (urlString);\n\n HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n uc.setRequestProperty (\"Authorization\", \" \" + encoding);\n\n url = uc.getResponseCode();\n\n\n }\n catch(MalformedURLException e){\n \t System.out.println(e);\n }catch(IOException e){\n System.out.println(e);\n }\n\n\n }\n}",
"import java.util.*;\nimport java.io.*;\nimport java.*;\n\npublic class Dogs5\n{\n public static void main(String [] args) throws Exception\n { \n executes(\"rm index.*\");\n executes(\"wget http://www.cs.rmit.edu./students\");\n\n while (true)\n {\n String addr= \"wget http://www.cs.rmit.edu./students\";\n executes(addr);\n String hash1 = md5sum(\"index.html\");\n String hash2 = md5sum(\"index.html.1\");\n System.out.println(hash1 +\"|\"+ hash2);\n \n BufferedReader buf = new BufferedReader(new FileReader(\"/home/k//Assign2/ulist1.txt\"));\n\n String line=\" \" ;\n String line1=\" \" ;\n String line2=\" \";\n String line3=\" \";\n String[] cad = new String[10];\n \n executes(\"./.sh\");\n \n int i=0;\n while ((line = buf.readLine()) != null)\n {\n \n line1=\"http://www.cs.rmit.edu./students/images\"+line;\n if (i==1)\n line2=\"http://www.cs.rmit.edu./students/images\"+line;\n if (i==2)\n line3=\"http://www.cs.rmit.edu./students/images\"+line;\n i++;\n }\n System.out.println(line1+\" \"+line2+\" \"+line3); \n\n\n executes(\"wget \"+line1);\n executes(\"wget \"+line2);\n executes(\"wget \"+line3);\n \n String hash3 = md5sum(\"index.html.2\"); \n String hash4 = md5sum(\"index.html.3\"); \n String hash5 = md5sum(\"index.html.4\");\n\n \n\n\nBufferedReader buf2 = new BufferedReader(new FileReader(\"/home/k//Assign2/ulist1.txt\"));\n\n String linee=\" \" ;\n String linee1=\" \" ;\n String linee2=\" \";\n String linee3=\" \";\n\n executes(\"./ip1.sh\");\n\n int j=0;\n while ((linee = buf2.readLine()) != null)\n {\n\n linee1=\"http://www.cs.rmit.edu./students/images\"+linee;\n if (j==1)\n linee2=\"http://www.cs.rmit.edu./students/images\"+linee;\n if (j==2)\n linee3=\"http://www.cs.rmit.edu./students/images\"+linee;\n j++;\n }\n System.out.println(line1+\" \"+line2+\" \"+line3);\n\n\n executes(\"wget \"+linee1);\n executes(\"wget \"+linee2);\n executes(\"wget \"+linee3);\n\n String hash6 = md5sum(\"index.html.5\");\n String hash7 = md5sum(\"index.html.6\");\n String hash8 = md5sum(\"index.html.7\"); \n \n boolean pict=false;\n if (hash3.equals(hash6))\n pict=true;\n\n boolean pict2=false;\n if (hash3.equals(hash6))\n pict2=true;\n \n boolean pict3=false;\n if (hash3.equals(hash6))\n pict3=true;\n\n \n if (hash1.equals(hash2))\n { \n executes(\"./difference.sh\");\n executes(\"./mail.sh\");\n \n \n\n }\n else\n {\n if (pict || pict2 || pict3)\n {\n executes(\".~/Assign2/difference.sh\"); \n executes(\".~/Assign2/mail2.sh\");\n }\n\n executes(\".~/Assign2/difference.sh\");\n executes(\".~/Assign2/mail.sh\");\n \n \n \n executes(\"./reorder.sh\");\n executes(\"rm index.html\");\n executes(\"cp index.html.1 index.html\");\n executes(\"rm index.html.1\");\n executes(\"sleep 5\"); \n } \n }\n }\n\n public static void executes(String comm) throws Exception\n {\n Process p = Runtime.getRuntime().exec(new String[]{\"/usr/local//bash\",\"-c\", comm });\n\n BufferedReader bf = new BufferedReader(new InputStreamReader(p.getErrorStream()));\n\n String cad;\n while(( cad = bf.readLine()) != null)\n {\n System.out.println();\n }\n\t p.waitFor();\n }\n\n public static String md5sum(String file) throws Exception\n {\n String cad;\n String hash= \" \"; \n\n Process p = Runtime.getRuntime().exec(new String[]{\"/usr/local//bash\",\n \"-c\", \"md5sum \"+file });\n BufferedReader bf = new BufferedReader(new InputStreamReader(p.getInputStream()));\n\n while((bf = cad.readLine()) != null)\n {\n StringTokenizer word=new StringTokenizer();\n hash=word.nextToken();\n System.out.println(hash);\n }\n return hash; \n\n }\n\n \n \n}\n\n",
"import java.io.*;\nimport java.*;\nimport java.net.*;\n\npublic class BruteForce\n{\n public static void main(String[] args) throws Exception\n {\n \n String password = checkPassword(); \n\n System.out.println(\"Congratulations Your password is \"+ password );\n \n \n\n URL url = new URL(\"http://sec-crack.cs.rmit.edu./SEC/2/\");\n HttpURLConnection sec = (HttpURLConnection)url.openConnection();\n sec.setRequestProperty(\"Authorization\", \" \" + encode(\":\"+password));\n BufferedReader in = new BufferedReader(new InputStreamReader(sec.getInputStream()));\n String inputLine;\n\n while ((inputLine = in.readLine()) != null)\n System.out.println(inputLine);\n in.close();\n }\n\n \n\n private static String checkPassword() throws Exception\n {\n String Password=\" \";\n int attempt=0;\n URL url = new URL(\"http://sec-crack.cs.rmit.edu./SEC/2/\");\n HttpURLConnection sec;\n String[] cad = {\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\"i\",\"j\",\"k\",\"l\",\"m\",\n \"n\",\"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"z\",\n \"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\",\"H\",\"I\",\"J\",\"K\",\"L\",\"M\",\n \"N\",\"O\",\"P\",\"Q\",\"R\",\"S\",\"T\",\"U\",\"V\",\"W\",\"X\",\"Y\",\"Z\"};\n\n for (int i=0; i < cad.length; i++)\n {\n for (int j=0; j< cad.length;j++)\n {\n for (int k=0; k<cad.length;k++)\n {\n attempt++;\n String Passwd = new String(cad[i]+cad[j]+cad[k]);\n String userPasswd= \":\"+Passwd;\n System.out.println(attempt+\" \"+userPasswd);\n \n sec = (HttpURLConnection)url.openConnection();\n sec.setRequestProperty(\"Authorization\", \" \" + encode(userPasswd));\n\n if (sec.getHeaderField(0).equals(\"HTTP/1.1 200 OK\"))\n {\n Password=Passwd;\n return Password;\n }\n sec.disconnect();\n } \n } \n } \n return \"Password not found\";\n }\n\n private static String encode(String userPasswd) throws Exception\n {\n String ad;\n String encodedUserPasswd=\" \";\n String addr= \"~//base64_encode.php \"+userPasswd ;\n Process p = Runtime.getRuntime().exec(new String[]{\"/usr/local//bash\",\"-c\", addr});\n BufferedReader resp = new BufferedReader(new InputStreamReader(p.getInputStream()));\n \n while ( (cad = resp.readLine()) != null )\n {\n \n encodedUserPasswd=cad;\n }\n return encodedUserPasswd;\n }\n}\n\n"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from huggingface/CodeBERTa-small-v1 on the soco_train_java dataset. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False, 'architecture': 'RobertaModel'})
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codeberta-cmnrl-triplets-ep1-bs256-lr5e-05-split0.2")
# Run inference
sentences = [
'\n\nimport java.net.*;\nimport java.io.*;\n\npublic class Base64Encoder\n{\n private final static char base64Array [] = {\n \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n };\n\n public static String encode (String string)\n {\n String encodedString = "";\n byte bytes [] = string.getBytes ();\n int i = 0;\n int pad = 0;\n while (i < bytes.length)\n {\n byte b1 = bytes [i++];\n byte b2;\n byte b3;\n if (i >= bytes.length)\n {\n b2 = 0;\n b3 = 0;\n pad = 2;\n }\n else\n {\n b2 = bytes [i++];\n if (i >= bytes.length)\n {\n b3 = 0;\n pad = 1;\n }\n else\n b3 = bytes [i++];\n }\n\n byte c1 = (byte)(b1 >> 2);\n byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n byte c4 = (byte)(b3 & 0x3f);\n encodedString += base64Array [c1];\n encodedString += base64Array [c2];\n switch (pad)\n {\n case 0:\n encodedString += base64Array [c3];\n encodedString += base64Array [c4];\n break;\n case 1:\n encodedString += base64Array [c3];\n encodedString += "=";\n break;\n case 2:\n encodedString += "==";\n break;\n }\n }\n return encodedString;\n }\n}\n',
'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class BruteForce {\n\n URLConnection conn = null;\n private static boolean status = false;\n\n public static void main (String args[]){\n BruteForce a = new BruteForce();\n String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n \t\t\t\t "",\n \t\t\t\t ""};\n int attempts = 0;\n exit:\n for (int i=0;i<pwdArray.length;i++) {\n\t\t for (int j=0;j<pwdArray.length;j++) {\n\t\t\t for (int k=0;k<pwdArray.length;k++) {\n\t\t\t\t if (pwdArray[i] == \' \' && pwdArray[j] != \' \') continue;\n\t\t\t\t if (pwdArray[j] == \' \' && pwdArray[k] != \' \') continue;\n\t\t\t\t inp[2] = inp[2] + pwdArray[i] + pwdArray[j] + pwdArray[k];\n\t\t\t\t attempts++;\n \t\t\t a.doit(inp);\n \n \t\t\t\t if (status) {\n\t\t\t\t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t\t\t System.out.println("Number of attempts = " + attempts);\n\t\t\t\t\t break exit;\n\t\t\t \t }\n \t\t\t inp[2] = "";\n\t\t \t }\n\t \t }\n }\n }\n\n public void doit(String args[]) {\n \n try {\n BufferedReader in = new BufferedReader(\n new InputStreamReader\n (connectURL(new URL(args[0]), args[1], args[2])));\n String line;\n while ((line = in.readLine()) != null) {\n System.out.println(line);\n status = true;\n }\n }\n catch (IOException e) {\n \n }\n }\n\n public InputStream connectURL (URL url, String uname, String pword)\n throws IOException {\n conn = url.openConnection();\n conn.setRequestProperty ("Authorization",\n userNamePasswordBase64(uname,pword));\n conn.connect ();\n return conn.getInputStream();\n }\n\n public String userNamePasswordBase64(String username, String password) {\n return " " + base64Encode (username + ":" + password);\n }\n\n private final static char pwdArray [] = {\n\t \'a\', \'b\', \'c\', \'d\', \'e\', \'f\', \'g\', \'h\',\n\t \'i\', \'j\', \'k\', \'l\', \'m\', \'n\', \'o\', \'p\',\n\t \'q\', \'r\', \'s\', \'t\', \'u\', \'v\', \'w\', \'x\',\n\t \'y\', \'z\', \'A\', \'B\', \'C\', \'D\', \'E\', \'F\',\n\t \'G\', \'H\', \'I\', \'J\', \'K\', \'L\', \'M\', \'N\',\n\t \'O\', \'P\', \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\',\n\t \'W\', \'X\', \'Y\', \'Z\', \' \'\n };\n\n private final static char base64Array [] = {\n \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n };\n\n private static String base64Encode (String string) {\n String encodedString = "";\n byte bytes [] = string.getBytes ();\n int i = 0;\n int pad = 0;\n while (i < bytes.length) {\n byte b1 = bytes [i++];\n byte b2;\n byte b3;\n if (i >= bytes.length) {\n b2 = 0;\n b3 = 0;\n pad = 2;\n }\n else {\n b2 = bytes [i++];\n if (i >= bytes.length) {\n b3 = 0;\n pad = 1;\n }\n else\n b3 = bytes [i++];\n }\n byte c1 = (byte)(b1 >> 2);\n byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n byte c4 = (byte)(b3 & 0x3f);\n encodedString += base64Array [c1];\n encodedString += base64Array [c2];\n switch (pad) {\n case 0:\n encodedString += base64Array [c3];\n encodedString += base64Array [c4];\n break;\n case 1:\n encodedString += base64Array [c3];\n encodedString += "=";\n break;\n case 2:\n encodedString += "==";\n break;\n }\n }\n return encodedString;\n }\n }\n\n',
'\nimport java.io.*;\nimport java.awt.*;\nimport java.net.*;\n\npublic class BruteForce\n{\n\tpublic static void main (String[] args)\n\t{\n\t\tString pw = new String();\n\t\tpw = getPassword ();\n\t\tSystem.out.println("Password is: "+pw);\n\t}\n\tpublic static String getPassword()\n\t{\n\t\tString passWord = new String();\n\t\tpassWord = "AAA";\n\t\tchar[] guess = passWord.toCharArray();\n\t\tProcess pro = null;\n\t\tRuntime runtime = Runtime.getRuntime();\n\t\tBufferedReader in = null;\n\t\tString str=null;\n\t\tboolean found = true;\n\n\t\tSystem.out.println(" attacking.....");\n\t\tfor (int i=65;i<=122 ;i++ )\n\t\t{\n\t\t\tguess[0]=(char)(i);\n for (int j=65;j<=122 ;j++ )\n\t\t\t{\n\t\t\t\tguess[1]=(char)(j);\n for (int k=65 ;k<=122 ;k++ )\n\t\t\t\t{\n\t\t\t\t\tguess[2]=(char)(k);\n\t\t\t\t\tpassWord = new String(guess);\n\t\t\t\t\tString cmd = "wget --http-user= --http-passwd="+passWord +" http://sec-crack.cs.rmit.edu./SEC/2/index.php ";\n\t\t\t\t\ttry\n\t\t\t\t\t{\n\t\t\t\t\t\tpro = runtime.exec(cmd);\n\n\t\t\t\t\t\tin = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\tif((str=in.readLine())!=null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\twhile ((str=in.readLine())!=null)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (found == true)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\treturn passWord;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch (Exception exception)\n\t\t\t\t\t{\n\t\t\t\t\t exception.getMessage();\n\t\t\t\t\t}\n\t\t\t\t\tif(k==90)\n\t\t\t\t\t\tk=96;\n\t\t\t\t\truntime.gc();\n\t\t\t\t}\n\t\t\t\tif(j==90)\n\t\t\t\t\tj=96;\n\t\t\t}\n\t\t\tif(i==90)\n\t\t\t\ti=96;\n\t\t}\n\t\treturn "not found";\n\t}\n}',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.9549, 0.5951],
# [0.9549, 1.0000, 0.5695],
# [0.5951, 0.5695, 1.0000]])
anchor_code, positive_code, and negative_code| anchor_code | positive_code | negative_code | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| anchor_code | positive_code | negative_code |
|---|---|---|
import java.util.; |
import java.util.; |
|
import java.util.; |
import java.util.; |
import java.net.; |
import java.net.; |
import java.net.; |
package java.httputils; |
CachedMultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim",
"mini_batch_size": 32,
"gather_across_devices": false
}
anchor_code, positive_code, and negative_code| anchor_code | positive_code | negative_code | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| anchor_code | positive_code | negative_code |
|---|---|---|
|
|
import java.net.; |
|
|
|
import java.io.; |
import java.io.; |
|
CachedMultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim",
"mini_batch_size": 32,
"gather_across_devices": false
}
per_device_train_batch_size: 256num_train_epochs: 1warmup_ratio: 0.1fp16: Truebatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: noprediction_loss_only: Trueper_device_train_batch_size: 256per_device_eval_batch_size: 8per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 5e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 1max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.1warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 42data_seed: Nonejit_mode_eval: Falseuse_ipex: Falsebf16: Falsefp16: Truefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseinclude_for_metrics: []eval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters: auto_find_batch_size: Falsefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 0.7407 | 100 | 0.4377 |
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084",
}
@misc{gao2021scaling,
title={Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup},
author={Luyu Gao and Yunyi Zhang and Jiawei Han and Jamie Callan},
year={2021},
eprint={2101.06983},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
Base model
huggingface/CodeBERTa-small-v1