CoolFace
Modelpublic

buelfhood/SOCO-Java-CodeT5Small-ST

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes26downloads
Model Card

SentenceTransformer based on Salesforce/codet5-small

This is a sentence-transformers model finetuned from Salesforce/codet5-small. It maps sentences & paragraphs to a 512-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.

Model Details

Model Description

  • Model Type: Sentence Transformer
  • Base model: Salesforce/codet5-small <!-- at revision b1ee9570c289f21b5922b9c768a1ce12957bf968 -->
  • Maximum Sequence Length: 512 tokens
  • Output Dimensionality: 512 dimensions
  • Similarity Function: Cosine Similarity <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: T5EncoderModel 
  (1): Pooling({'word_embedding_dimension': 512, '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})
)

Usage

Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-CodeT5Small-ST")
# Run inference
sentences = [
    '\n\n\n\n\n\nimport java.io.*;\nimport java.net.*;\n\n\n\npublic class Dictionary\n{\n   public static void main (String args[]) throws IOException,\n   MalformedURLException\n   {\n      final String username = "";\n      final String fullurl = "http://sec-crack.cs.rmit.edu./SEC/2/";\n      final String dictfile = "/usr/share/lib/dict/words";\n      String temppass;\n      String password = "";\n      URL url = new URL(fullurl);\n      boolean cracked = false;\n\n       startTime = System.currentTimeMillis();\n\n      \n      BufferedReader r = new BufferedReader(new FileReader(dictfile));\n\n      while((temppass = r.readLine()) != null && !cracked)\n      {  \n         \n         if(temppass.length() <= 3)\n         {\n            \n            if(isAlpha(temppass))\n            {\n               \n               Authenticator.setDefault(new MyAuthenticator(username,temppass));\n               try{\n                  BufferedReader x = new BufferedReader(new InputStreamReader(\n                     url.openStream()));\n                  cracked = true;\n                  password = temppass;\n               } catch(Exception e){}\n            }\n         }\n      }\n\n       stopTime = System.currentTimeMillis();\n      \n      if(!cracked)\n         System.out.println("Sorry, couldnt find the password");\n      else\n         System.out.println("Password found: "+password);\n      System.out.println("Time taken: "+(stopTime-startTime));\n   }\n\n   public static boolean isAlpha(String s)\n   {\n      boolean v = true;\n      for(int i=0; i<s.length(); i++)\n      {\n         if(!Character.isLetter(s.charAt(i)))\n            v = false;\n      }\n      return ;\n   }\n}\n\n',
    '\n\nimport java.net.*;\nimport java.text.*;  \nimport java.util.*;  \nimport java.io.*;\n\npublic class WatchDog {\n\n  public WatchDog() {\n\n    StringBuffer stringBuffer1 = new StringBuffer();\n    StringBuffer stringBuffer2 = new StringBuffer();\n    int i,j = 0;\n\n    try{\n\n      URL yahoo = new URL("http://www.cs.rmit.edu./students/"); \n      BufferedReader in = new BufferedReader(new InputStreamReader(yahoo.openStream()));\n\n      String inputLine = "";\n      String inputLine1 = "";\n      String changedtext= "";\n      String changedflag= "";\n\n\n      Thread.sleep(180);\n\n      BufferedReader in1 = new BufferedReader(new InputStreamReader(yahoo.openStream()));\n\n\n      while ((inputLine = in.readLine()) != null) {\n           inputLine1 = in1.readLine();\n           if (inputLine.equals(inputLine1)) {\n              System.out.println("equal");\n           }\n           else {\n              System.out.println("Detected a Change");\n              System.out.println("Line Before the change:" + inputLine);\n              System.out.println("Line After the change:" + inputLine1);\n              changedtext = changedtext + inputLine + inputLine1;\n              changedflag = "Y";\n           }\n           \n      }\n\n      if (in1.readLine() != null ) {\n         System.out.println("Detected a Change");\n         System.out.println("New Lines Added  ");\n         changedtext = changedtext + "New Lines added";\n         changedflag = "Y";\n      }\n\n      in.print();\n      in1.print();\n\n      if (changedflag.equals("Y")) {\n         String smtphost ="smtp.mail.rmit.edu." ; \n         String from = "@rmit.edu."; \n         String  = "janaka1@optusnet.." ; \n      }\n\n\n    }\n    catch(Exception e){ System.out.println("exception:" + e);}\n\t \n}\n\t\t\n    public static void main (String[] args) throws Exception {\n\t\tWatchDog u = new WatchDog();\n    }\n}\n',
    '\n\n\n\nimport java.util.*;\nimport java.net.*;\nimport java.io.*;\nimport javax.swing.*;\n\npublic class PasswordCombination\n{\n    private int      pwdCounter = 0;\n    private   int   startTime;\n    private String   str1,str2,str3;\n    private String   url = "http://sec-crack.cs.rmit.edu./SEC/2/";\n    private String   loginPwd;\n    private String[] password;\n    private HoldSharedData data;\n    private char[] chars = {\'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    public PasswordCombination()\n    {\n        System.out.println("Programmed by   for INTE1070 Assignment 2");\n\n        String input = JOptionPane.showInputDialog( "Enter number of threads" );\n        if(  input == null  )\n           System.exit(0);\n\n        int numOfConnections = Integer.parseInt( input );\n        startTime = System.currentTimeMillis();\n        int pwdCounter = 52*52*52 + 52*52 + 52;\n        password = new String[pwdCounter];\n\n\n        loadPasswords();\n        System.out.println( "Total Number of Passwords: " + pwdCounter );\n        createConnectionThread( numOfConnections );\n    }\n\n    private void doPwdCombination()\n    {\n        for( int i = 0; i < 52; i ++ )\n        {\n            str1 = "" + chars[i];\n            password[pwdCounter++] = "" + chars[i];\n            System.err.print( str1 + " | " );\n\n            for( int j = 0; j < 52; j ++ )\n            {\n                str2 = str1 + chars[j];\n                password[pwdCounter++] = str1 + chars[j];\n\n                for( int k = 0; k < 52; k ++ )\n                {\n                    str3 = str2 + chars[k];\n                    password[pwdCounter++] = str2 + chars[k];\n                }\n            }\n        }\n    }\n\n    private void loadPasswords( )\n    {\n        FileReader     fRead;\n        BufferedReader buf;\n        String         line = null;\n        String         fileName = "words";\n\n        try\n        {\n            fRead = new FileReader( fileName );\n            buf = new BufferedReader(fRead);\n\n            while((line = buf.readLine( )) != null)\n            {\n                password[pwdCounter++] = line;\n            }\n        }\n        catch(FileNotFoundException e)\n        {\n            System.err.println("File not found: " + fileName);\n        }\n        catch(IOException ioe)\n        {\n            System.err.println("IO Error " + ioe);\n        }\n    }\n\n    private void createConnectionThread( int input )\n    {\n        data = new HoldSharedData( startTime, password, pwdCounter );\n\n        int numOfThreads = input;\n        int batch = pwdCounter/numOfThreads + 1;\n        numOfThreads = pwdCounter/batch + 1;\n        System.out.println("Number of Connection Threads Used=" + numOfThreads);\n        ConnectionThread[] connThread = new ConnectionThread[numOfThreads];\n\n        for( int index = 0; index < numOfThreads; index ++ )\n        {\n            connThread[index] = new ConnectionThread( url, index, batch, data );\n            connThread[index].conn();\n        }\n    }\n}  ',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

Unnamed Dataset
  • Size: 33,411 training samples
  • Columns: <code>sentence0</code>, <code>sentence1</code>, and <code>label</code>
  • Approximate statistics based on the first 1000 samples: | | sentence0 | sentence1 | label | |:--------|:-------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------|:-----------------------------------------------| | type | string | string | int | | details | <ul><li>min: 52 tokens</li><li>mean: 444.58 tokens</li><li>max: 512 tokens</li></ul> | <ul><li>min: 52 tokens</li><li>mean: 470.35 tokens</li><li>max: 512 tokens</li></ul> | <ul><li>0: ~99.80%</li><li>1: ~0.20%</li></ul> |
  • Samples: | sentence0 | sentence1 | label | |:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------| | <code> <br><br><br><br><br>import java.util.;<br>import java.io.;<br><br>public class MyTimer<br>{ <br><br> public static void main(String args[])<br> {<br> Watchdog watch = new Watchdog();<br> Timer time = new Timer();<br> time.schedule(watch,864000000,864000000);<br> <br> <br> }<br>}<br></code> | <code><br><br>import java.io.;<br>import java.;<br>import java.net.;<br>import java.util.;<br><br>public class Dictionary {<br> public static void main (String[] args) throws IOException {<br> BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));<br><br> d = new Date().getTime();<br> FileReader fr = new FileReader("/usr/share/lib/dict/words");<br> BufferedReader bufr = new BufferedReader(fr);<br> String word = bufr.readLine(); <br> int total = 960;<br> String[] pws = new String[total];<br> int count = 0;<br> while (word!=null){<br> if (word.length()<=3) { pws[count] = word; count++;}<br> word = bufr.readLine();<br> }<br> <br> int i=0;<br> int response = 0;<br> for (i=0;i<count;i++){<br> String uname = "";<br> String userinfo = uname + ":" + pws[i];<br> try{<br> String encoding = new bf.misc.BASE64Encoder().encode (userinfo.getBytes());<br> URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");<br> HttpURLConn...</code> | <code>0</code> | | <code><br>import java.io.;<br>import java.util.;<br><br><br>class BruteForce{<br><br>public static void main(String args[]){<br><br>String pass,s;<br>char a,b,c;<br>int z=0;<br>int attempt=0;<br>Process p;<br><br><br>char password[]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q',<br> 'R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h',<br> 'i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};<br> z = System.currentTimeMillis();<br>int at=0;<br>for(int i=0;i<password.length;i++){<br> for(int j=0;j<password.length;j++){<br> for(int k=0;k<password.length;k++){<br> pass=String.valueOf(password[i])+String.valueOf(password[j])+String.valueOf(password[k]);<br><br> try {<br> System.out.println("Trying crack using: "+pass);<br> at++;<br><br><br> p = Runtime.getRuntime().exec("wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php");<br> try{<br> p.waitFor();<br> }<br> catch(Exception q){}<br><br><br> z = p.exitValue();<br><br><br> ...</code> | <code><br>import java.io.;<br>import java.util.Vector;<br>import java.util.Date;<br><br><br>interface UnaryPredicate {<br> boolean execute(Object obj);<br>}<br><br><br>public class DiffPrint {<br> <br> static String outFile="";<br><br> public static abstract class Base {<br> protected Base(Object[] a,Object[] b) {<br> try<br> {<br> outfile = new PrintWriter(new FileWriter(outFile)); <br> }<br> catch (Exception e)<br> {<br> e.printStackTrace();<br> }<br> file0 = a;<br> file1 = b;<br> }<br> <br> protected UnaryPredicate ignore = null;<br><br> <br> protected Object[] file0, file1;<br><br> <br> public void print_script(Diff.change script) {<br> Diff.change next = script;<br><br> while (next != null)<br> {<br> Diff.change t, end;<br><br> <br> t = next;<br> end = hunkfun(next);<br><br> <br> next = end;<br> end = null;<br> <br> <br><br> <br> print_hunk(t);<br><br> <br> end = next;<br> }<br> outfile.flush();<br> }<br><br> <br><br> protected Diff.change hunkfun(Diff.change hunk) {<br> ...</code> | <code>0</code> | | <code>package java.httputils;<br><br>import java.io.BufferedInputStream;<br>import java.io.BufferedOutputStream;<br>import java.io.BufferedReader;<br>import java.io.FileInputStream;<br>import java.io.FileNotFoundException;<br>import java.io.FileOutputStream;<br>import java.io.FileReader;<br>import java.io.IOException;<br>import java.io.OutputStream;<br><br><br>public class WatchDog<br>{<br> protected final int MILLIS_IN_HOUR = (60 60 1000);<br> protected int interval = 24;<br> protected String URL = "http://www.cs.rmit.edu./students/";<br> protected String fileName = "WatchDogContent.html";<br> protected String command = "./alert_mail.sh";<br> protected String savedContent;<br> protected String retrievedContent;<br><br> <br> public WatchDog()<br> {<br> super();<br> }<br><br> <br> public void run() throws Exception<br> {<br> HttpRequestClient client = null;<br> <br> <br> System.out.println(getClass().getName() +<br> "Retrieving baseline copy of: " + getURL());<br> client = new HttpRequestClie...</code> | <code><br><br>import java.;<br>import java.io.;<br>import java.util.;<br><br>public class Dictionary<br>{<br> public String[] passwds;<br> public int passwdNum;<br> public static void main(String[] args) throws IOException<br> {<br> Dictionary dic=new Dictionary();<br> dic.doDictionary();<br> System.exit(1);<br> }<br><br> void doDictionary() throws IOException<br> {<br> Runtime rt=Runtime.getRuntime();<br> passwds=new String[32768];<br> passwdNum=0;<br><br> time1=new Date().getTime();<br> <br> try<br> {<br> File f = new File ("words");<br> FileReader fin = new FileReader (f);<br> BufferedReader buf = new BufferedReader(fin);<br> passwds[0]="00";<br> System.out.println(" loading words....");<br> <br> {<br> passwds[passwdNum]=buf.readLine();<br> passwdNum++;<br> }while(passwds[passwdNum-1]!=null);<br> System.out.println("Finish loading words.");<br> } catch (FileNotFoundException exc) {<br> System.out.println ("File Not Found");<br> } catch (IOException exc) {<br> System.out.println ("IOException 1");<br> } catch (NullPointerException exc) {<br> System.out.println ("NullPointerEx...</code> | <code>0</code> |
  • Loss: <code>BatchAllTripletLoss</code>

Training Hyperparameters

Non-Default Hyperparameters
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • num_train_epochs: 1
  • multi_dataset_batch_sampler: round_robin
All Hyperparameters

<details><summary>Click to expand</summary>

  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: no
  • prediction_loss_only: True
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • per_gpu_train_batch_size: None
  • per_gpu_eval_batch_size: None
  • gradient_accumulation_steps: 1
  • eval_accumulation_steps: None
  • torch_empty_cache_steps: None
  • learning_rate: 5e-05
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1
  • num_train_epochs: 1
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.0
  • warmup_steps: 0
  • log_level: passive
  • log_level_replica: warning
  • log_on_each_node: True
  • logging_nan_inf_filter: True
  • save_safetensors: True
  • save_on_each_node: False
  • save_only_model: False
  • restore_callback_states_from_checkpoint: False
  • no_cuda: False
  • use_cpu: False
  • use_mps_device: False
  • seed: 42
  • data_seed: None
  • jit_mode_eval: False
  • use_ipex: False
  • bf16: False
  • fp16: False
  • fp16_opt_level: O1
  • half_precision_backend: auto
  • bf16_full_eval: False
  • fp16_full_eval: False
  • tf32: None
  • local_rank: 0
  • ddp_backend: None
  • tpu_num_cores: None
  • tpu_metrics_debug: False
  • debug: []
  • dataloader_drop_last: False
  • dataloader_num_workers: 0
  • dataloader_prefetch_factor: None
  • past_index: -1
  • disable_tqdm: False
  • remove_unused_columns: True
  • label_names: None
  • load_best_model_at_end: False
  • ignore_data_skip: False
  • fsdp: []
  • fsdp_min_num_params: 0
  • fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • ddp_find_unused_parameters: None
  • ddp_bucket_cap_mb: None
  • ddp_broadcast_buffers: False
  • dataloader_pin_memory: True
  • dataloader_persistent_workers: False
  • skip_memory_metrics: True
  • use_legacy_prediction_loop: False
  • push_to_hub: False
  • resume_from_checkpoint: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_private_repo: None
  • hub_always_push: False
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_inputs_for_metrics: False
  • include_for_metrics: []
  • eval_do_concat_batches: True
  • fp16_backend: auto
  • push_to_hub_model_id: None
  • push_to_hub_organization: None
  • mp_parameters:
  • auto_find_batch_size: False
  • full_determinism: False
  • torchdynamo: None
  • ray_scope: last
  • ddp_timeout: 1800
  • torch_compile: False
  • torch_compile_backend: None
  • torch_compile_mode: None
  • include_tokens_per_second: False
  • include_num_input_tokens_seen: False
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • eval_use_gather_object: False
  • average_tokens_across_devices: False
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: round_robin

</details>

Training Logs

EpochStepTraining Loss
0.23935000.2122
0.478710000.1686
0.718015000.2193
0.957420000.2084

Framework Versions

  • Python: 3.11.13
  • Sentence Transformers: 4.1.0
  • Transformers: 4.52.4
  • PyTorch: 2.6.0+cu124
  • Accelerate: 1.7.0
  • Datasets: 3.6.0
  • Tokenizers: 0.21.1

Citation

BibTeX

Sentence Transformers
bibtex
@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",
}
BatchAllTripletLoss
bibtex
@misc{hermans2017defense,
    title={In Defense of the Triplet Loss for Person Re-Identification},
    author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
    year={2017},
    eprint={1703.07737},
    archivePrefix={arXiv},
    primaryClass={cs.CV}
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->