Shuu12121's picture
Upload ModernBERT model
6b0a938 verified
metadata
tags:
  - sentence-transformers
  - sentence-similarity
  - feature-extraction
  - dense
  - generated_from_trainer
  - dataset_size:58800
  - loss:MultipleNegativesRankingLoss
base_model: Shuu12121/CodeModernBERT-Finch
widget:
  - source_sentence: >-
      Returns boolean indicating whether the requestUrl matches against the
      paths configured.


      @param requestedUrl - url requested by user

      @param opts - unless configuration

      @returns {boolean}
    sentences:
      - |-
        def xmoe2_v1_l4k_global_only():
          """"""
          hparams = xmoe2_v1_l4k()
          hparams.decoder_layers = [
              "att" if l == "local_att" else l for l in hparams.decoder_layers]
          return hparams
      - |-
        function matchesPath(requestedUrl, opts) {
          var paths = !opts.path || Array.isArray(opts.path) ?
            opts.path : [opts.path];

          if (paths) {
            return paths.some(function(p) {
              return (typeof p === 'string' && p === requestedUrl.pathname) ||
                (p instanceof RegExp && !! p.exec(requestedUrl.pathname));
            });
          }

          return false;
        }
      - |-
        public static function factory($accessToken, $currentTeam)
            {
                $client = Client::factory($accessToken);

                return new self($client, $currentTeam);
            }
  - source_sentence: >-
      // New creates a new ImageGraphics including an image.RGBA of dimension w
      x h

      // with background bgcol. If font is nil it will use a builtin font.

      // If fontsize is empty useful default are used.
    sentences:
      - "func New(width, height int, bgcol color.RGBA, font *truetype.Font, fontsize map[chart.FontSize]float64) *ImageGraphics {\n\timg := image.NewRGBA(image.Rect(0, 0, width, height))\n\tgc := draw2dimg.NewGraphicContext(img)\n\tgc.SetLineJoin(draw2d.BevelJoin)\n\tgc.SetLineCap(draw2d.SquareCap)\n\tgc.SetStrokeColor(image.Black)\n\tgc.SetFillColor(bgcol)\n\tgc.Translate(0.5, 0.5)\n\tgc.Clear()\n\tif font == nil {\n\t\tfont = defaultFont\n\t}\n\tif len(fontsize) == 0 {\n\t\tfontsize = ConstructFontSizes(13)\n\t}\n\treturn &ImageGraphics{Image: img, x0: 0, y0: 0, w: width, h: height,\n\t\tbg: bgcol, gc: gc, font: font, fs: fontsize}\n}"
      - >-
        public static void requestDataLogsForApp(final Context context, final
        UUID appUuid) {
                final Intent requestIntent = new Intent(INTENT_DL_REQUEST_DATA);
                requestIntent.putExtra(APP_UUID, appUuid);
                context.sendBroadcast(requestIntent);
            }
      - |-
        final protected function setWriteMode($mode)
            {
                if (!in_array($mode, [static::WRITE_MODE_INSERT, static::WRITE_MODE_UPSERT, static::WRITE_MODE_UPDATE])) {
                    throw new \InvalidArgumentException(sprintf('Passed write mode "%s" is invalid!', $mode));
                }
                $this->writeMode = $mode;
            }
  - source_sentence: |-
      Builds the path for a closed arc, returning a PolygonOptions that can be
      further customised before use.

      @param center
      @param start
      @param end
      @param arcType Pass in either ArcType.CHORD or ArcType.ROUND
      @return PolygonOptions with the paths element populated.
    sentences:
      - |-
        function getJavaScriptCallbackParameterListSimple(parameters) {
            var result = []

            parameters.forEach(function(parameter){
                if (!parameter.out) return
                result.push("/*" + getIdlType(parameter.type) + "*/ "+ parameter.name)
            })

            return result.join(", ")
        }
      - "public Color getBackground() {\r\n\t\tpredraw();\r\n\t\tFloatBuffer buffer = BufferUtils.createFloatBuffer(16);\r\n\t\tGL.glGetFloat(SGL.GL_COLOR_CLEAR_VALUE, buffer);\r\n\t\tpostdraw();\r\n\r\n\t\treturn new Color(buffer);\r\n\t}"
      - >-
        public static final PolygonOptions buildClosedArc(LatLong center,
        LatLong start, LatLong end, ArcType arcType) {
                MVCArray res = buildArcPoints(center, start, end);
                if (ArcType.ROUND.equals(arcType)) {
                    res.push(center);
                }
                return new PolygonOptions().paths(res);
            }
  - source_sentence: |-
      Read data from a spread sheet. Return the data in a dict with
          column numbers as keys.

          sheet: xlrd.sheet.Sheet instance
              Ready for use.

          startstops: list
              Four StartStop objects defining the data to read. See
              :func:`~channelpack.pullxl.prepread`.

          usecols: str or seqence of ints or None
              The columns to use, 0-based. 0 is the spread sheet column
              "A". Can be given as a string also - 'C:E, H' for columns C, D,
              E and H.

          Values in the returned dict are numpy arrays. Types are set based on
          the types in the spread sheet.
    sentences:
      - |-
        public function handleScanNotify(callable $callback)
            {
                $notify = $this->getNotify();

                if (!$notify->isValid()) {
                    throw new FaultException('Invalid request payloads.', 400);
                }

                $notify = $notify->getNotify();

                try {
                    $prepayId = call_user_func_array($callback, [$notify->get('product_id'), $notify->get('openid'), $notify]);
                    $response = [
                        'return_code' => 'SUCCESS',
                        'appid'       => $this->merchant->app_id,
                        'mch_id'      => $this->merchant->merchant_id,
                        'nonce_str'   => uniqid(),
                        'prepay_id'   => strval($prepayId),
                        'result_code' => 'SUCCESS',
                    ];
                    $response['sign'] = generate_sign($response, $this->merchant->key);
                } catch (\Exception $e) {
                    $response = [
                        'return_code'  => 'SUCCESS',
                        'return_msg'   => $e->getCode(),
                        'result_code'  => 'FAIL',
                        'err_code_des' => $e->getMessage(),
                    ];
                }

                return new Response(XML::build($response));
            }
      - |-
        def _sheet_asdict(sheet, startstops, usecols=None):
            """
            """

            _, _, start, stop = startstops
            usecols = _sanitize_usecols(usecols)

            if usecols is not None:
                iswithin = start.col <= min(usecols) and stop.col > max(usecols)
                mess = 'Column in usecols outside defined data range, got '
                assert iswithin, mess + str(usecols)
            else:                       # usecols is None.
                usecols = tuple(range(start.col, stop.col))

            # cols = usecols or range(start.col, stop.col)
            D = dict()

            for c in usecols:
                cells = sheet.col(c, start_rowx=start.row, end_rowx=stop.row)
                types = set([cell.ctype for cell in cells])

                # Replace empty values with nan if appropriate:
                if (not types - NANABLE) and xlrd.XL_CELL_NUMBER in types:
                    D[c] = np.array([np.nan if cell.value == '' else cell.value
                                     for cell in cells])
                elif xlrd.XL_CELL_DATE in types:
                    dm = sheet.book.datemode
                    vals = []
                    for cell in cells:
                        if cell.ctype == xlrd.XL_CELL_DATE:
                            dtuple = xlrd.xldate_as_tuple(cell.value, dm)
                            vals.append(datetime.datetime(*dtuple))
                        elif cell.ctype in NONABLES:
                            vals.append(None)
                        else:
                            vals.append(cell.value)
                    D[c] = np.array(vals)
                else:
                    vals = [None if cell.ctype in NONABLES else cell.value
                            for cell in cells]
                    D[c] = np.array(vals)

            return D
      - "func (o Option) RequiresOption(name string) bool {\n\tfor _, o := range o.Requires {\n\t\tif o == name {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}"
  - source_sentence: |-
      // reBuild partially rebuilds a site given the filesystem events.
      // It returns whetever the content source was changed.
      // TODO(bep) clean up/rewrite this method.
    sentences:
      - "func WebPageImageResolver(doc *goquery.Document) ([]candidate, int) {\n\timgs := doc.Find(\"img\")\n\n\tvar candidates []candidate\n\tsignificantSurface := 320 * 200\n\tsignificantSurfaceCount := 0\n\tsrc := \"\"\n\timgs.Each(func(i int, tag *goquery.Selection) {\n\t\tvar surface int\n\t\tsrc = getImageSrc(tag)\n\t\tif src == \"\" {\n\t\t\treturn\n\t\t}\n\n\t\twidth, _ := tag.Attr(\"width\")\n\t\theight, _ := tag.Attr(\"height\")\n\t\tif width != \"\" {\n\t\t\tw, _ := strconv.Atoi(width)\n\t\t\tif height != \"\" {\n\t\t\t\th, _ := strconv.Atoi(height)\n\t\t\t\tsurface = w * h\n\t\t\t} else {\n\t\t\t\tsurface = w\n\t\t\t}\n\t\t} else {\n\t\t\tif height != \"\" {\n\t\t\t\tsurface, _ = strconv.Atoi(height)\n\t\t\t} else {\n\t\t\t\tsurface = 0\n\t\t\t}\n\t\t}\n\n\t\tif surface > significantSurface {\n\t\t\tsignificantSurfaceCount++\n\t\t}\n\n\t\ttagscore := score(tag)\n\t\tif tagscore >= 0 {\n\t\t\tc := candidate{\n\t\t\t\turl:     src,\n\t\t\t\tsurface: surface,\n\t\t\t\tscore:   score(tag),\n\t\t\t}\n\t\t\tcandidates = append(candidates, c)\n\t\t}\n\t})\n\n\tif len(candidates) == 0 {\n\t\treturn nil, 0\n\t}\n\n\treturn candidates, significantSurfaceCount\n\n}"
      - "@SuppressWarnings(\"rawtypes\")\n\tpublic void open(Map conf, TopologyContext context,\n\t\t\tSpoutOutputCollector collector) {\n\t\tif(this.jmsProvider == null){\n\t\t\tthrow new IllegalStateException(\"JMS provider has not been set.\");\n\t\t}\n\t\tif(this.tupleProducer == null){\n\t\t\tthrow new IllegalStateException(\"JMS Tuple Producer has not been set.\");\n\t\t}\n\t\tInteger topologyTimeout = (Integer)conf.get(\"topology.message.timeout.secs\");\n\t\t// TODO fine a way to get the default timeout from storm, so we're not hard-coding to 30 seconds (it could change)\n\t\ttopologyTimeout = topologyTimeout == null ? 30 : topologyTimeout;\n\t\tif( (topologyTimeout.intValue() * 1000 )> this.recoveryPeriod){\n\t\t    LOG.warn(\"*** WARNING *** : \" +\n\t\t    \t\t\"Recovery period (\"+ this.recoveryPeriod + \" ms.) is less then the configured \" +\n\t\t    \t\t\"'topology.message.timeout.secs' of \" + topologyTimeout + \n\t\t    \t\t\" secs. This could lead to a message replay flood!\");\n\t\t}\n\t\tthis.queue = new LinkedBlockingQueue<Message>();\n\t\tthis.toCommit = new TreeSet<JmsMessageID>();\n        this.pendingMessages = new HashMap<JmsMessageID, Message>();\n\t\tthis.collector = collector;\n\t\ttry {\n\t\t\tConnectionFactory cf = this.jmsProvider.connectionFactory();\n\t\t\tDestination dest = this.jmsProvider.destination();\n\t\t\tthis.connection = cf.createConnection();\n\t\t\tthis.session = connection.createSession(false,\n\t\t\t\t\tthis.jmsAcknowledgeMode);\n\t\t\tMessageConsumer consumer = session.createConsumer(dest);\n\t\t\tconsumer.setMessageListener(this);\n\t\t\tthis.connection.start();\n\t\t\tif (this.isDurableSubscription() && this.recoveryPeriod > 0){\n\t\t\t    this.recoveryTimer = new Timer();\n\t\t\t    this.recoveryTimer.scheduleAtFixedRate(new RecoveryTask(), 10, this.recoveryPeriod);\n\t\t\t}\n\t\t\t\n\t\t} catch (Exception e) {\n\t\t\tLOG.warn(\"Error creating JMS connection.\", e);\n\t\t}\n\n\t}"
      - "func (s *Site) processPartial(events []fsnotify.Event) (whatChanged, error) {\n\n\tevents = s.filterFileEvents(events)\n\tevents = s.translateFileEvents(events)\n\n\ts.Log.DEBUG.Printf(\"Rebuild for events %q\", events)\n\n\th := s.h\n\n\t// First we need to determine what changed\n\n\tvar (\n\t\tsourceChanged       = []fsnotify.Event{}\n\t\tsourceReallyChanged = []fsnotify.Event{}\n\t\tcontentFilesChanged []string\n\t\ttmplChanged         = []fsnotify.Event{}\n\t\tdataChanged         = []fsnotify.Event{}\n\t\ti18nChanged         = []fsnotify.Event{}\n\t\tshortcodesChanged   = make(map[string]bool)\n\t\tsourceFilesChanged  = make(map[string]bool)\n\n\t\t// prevent spamming the log on changes\n\t\tlogger = helpers.NewDistinctFeedbackLogger()\n\t)\n\n\tcachePartitions := make([]string, len(events))\n\n\tfor i, ev := range events {\n\t\tcachePartitions[i] = resources.ResourceKeyPartition(ev.Name)\n\n\t\tif s.isContentDirEvent(ev) {\n\t\t\tlogger.Println(\"Source changed\", ev)\n\t\t\tsourceChanged = append(sourceChanged, ev)\n\t\t}\n\t\tif s.isLayoutDirEvent(ev) {\n\t\t\tlogger.Println(\"Template changed\", ev)\n\t\t\ttmplChanged = append(tmplChanged, ev)\n\n\t\t\tif strings.Contains(ev.Name, \"shortcodes\") {\n\t\t\t\tshortcode := filepath.Base(ev.Name)\n\t\t\t\tshortcode = strings.TrimSuffix(shortcode, filepath.Ext(shortcode))\n\t\t\t\tshortcodesChanged[shortcode] = true\n\t\t\t}\n\t\t}\n\t\tif s.isDataDirEvent(ev) {\n\t\t\tlogger.Println(\"Data changed\", ev)\n\t\t\tdataChanged = append(dataChanged, ev)\n\t\t}\n\t\tif s.isI18nEvent(ev) {\n\t\t\tlogger.Println(\"i18n changed\", ev)\n\t\t\ti18nChanged = append(dataChanged, ev)\n\t\t}\n\t}\n\n\t// These in memory resource caches will be rebuilt on demand.\n\tfor _, s := range s.h.Sites {\n\t\ts.ResourceSpec.ResourceCache.DeletePartitions(cachePartitions...)\n\t}\n\n\tif len(tmplChanged) > 0 || len(i18nChanged) > 0 {\n\t\tsites := s.h.Sites\n\t\tfirst := sites[0]\n\n\t\ts.h.init.Reset()\n\n\t\t// TOD(bep) globals clean\n\t\tif err := first.Deps.LoadResources(); err != nil {\n\t\t\treturn whatChanged{}, err\n\t\t}\n\n\t\tfor i := 1; i < len(sites); i++ {\n\t\t\tsite := sites[i]\n\t\t\tvar err error\n\t\t\tdepsCfg := deps.DepsCfg{\n\t\t\t\tLanguage:      site.language,\n\t\t\t\tMediaTypes:    site.mediaTypesConfig,\n\t\t\t\tOutputFormats: site.outputFormatsConfig,\n\t\t\t}\n\t\t\tsite.Deps, err = first.Deps.ForLanguage(depsCfg, func(d *deps.Deps) error {\n\t\t\t\td.Site = &site.Info\n\t\t\t\treturn nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn whatChanged{}, err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(dataChanged) > 0 {\n\t\ts.h.init.data.Reset()\n\t}\n\n\tfor _, ev := range sourceChanged {\n\t\tremoved := false\n\n\t\tif ev.Op&fsnotify.Remove == fsnotify.Remove {\n\t\t\tremoved = true\n\t\t}\n\n\t\t// Some editors (Vim) sometimes issue only a Rename operation when writing an existing file\n\t\t// Sometimes a rename operation means that file has been renamed other times it means\n\t\t// it's been updated\n\t\tif ev.Op&fsnotify.Rename == fsnotify.Rename {\n\t\t\t// If the file is still on disk, it's only been updated, if it's not, it's been moved\n\t\t\tif ex, err := afero.Exists(s.Fs.Source, ev.Name); !ex || err != nil {\n\t\t\t\tremoved = true\n\t\t\t}\n\t\t}\n\t\tif removed && IsContentFile(ev.Name) {\n\t\t\th.removePageByFilename(ev.Name)\n\t\t}\n\n\t\tsourceReallyChanged = append(sourceReallyChanged, ev)\n\t\tsourceFilesChanged[ev.Name] = true\n\t}\n\n\tfor shortcode := range shortcodesChanged {\n\t\t// There are certain scenarios that, when a shortcode changes,\n\t\t// it isn't sufficient to just rerender the already parsed shortcode.\n\t\t// One example is if the user adds a new shortcode to the content file first,\n\t\t// and then creates the shortcode on the file system.\n\t\t// To handle these scenarios, we must do a full reprocessing of the\n\t\t// pages that keeps a reference to the changed shortcode.\n\t\tpagesWithShortcode := h.findPagesByShortcode(shortcode)\n\t\tfor _, p := range pagesWithShortcode {\n\t\t\tcontentFilesChanged = append(contentFilesChanged, p.File().Filename())\n\t\t}\n\t}\n\n\tif len(sourceReallyChanged) > 0 || len(contentFilesChanged) > 0 {\n\t\tvar filenamesChanged []string\n\t\tfor _, e := range sourceReallyChanged {\n\t\t\tfilenamesChanged = append(filenamesChanged, e.Name)\n\t\t}\n\t\tif len(contentFilesChanged) > 0 {\n\t\t\tfilenamesChanged = append(filenamesChanged, contentFilesChanged...)\n\t\t}\n\n\t\tfilenamesChanged = helpers.UniqueStrings(filenamesChanged)\n\n\t\tif err := s.readAndProcessContent(filenamesChanged...); err != nil {\n\t\t\treturn whatChanged{}, err\n\t\t}\n\n\t}\n\n\tchanged := whatChanged{\n\t\tsource: len(sourceChanged) > 0 || len(shortcodesChanged) > 0,\n\t\tother:  len(tmplChanged) > 0 || len(i18nChanged) > 0 || len(dataChanged) > 0,\n\t\tfiles:  sourceFilesChanged,\n\t}\n\n\treturn changed, nil\n\n}"
pipeline_tag: sentence-similarity
library_name: sentence-transformers

SentenceTransformer based on Shuu12121/CodeModernBERT-Finch

This is a sentence-transformers model finetuned from Shuu12121/CodeModernBERT-Finch. 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: Shuu12121/CodeModernBERT-Finch
  • Maximum Sequence Length: 1024 tokens
  • Output Dimensionality: 512 dimensions
  • Similarity Function: Cosine Similarity

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 1024, 'do_lower_case': False, 'architecture': 'ModernBertModel'})
  (1): Pooling({'word_embedding_dimension': 512, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, '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:

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("sentence_transformers_model_id")
# Run inference
sentences = [
    '// reBuild partially rebuilds a site given the filesystem events.\n// It returns whetever the content source was changed.\n// TODO(bep) clean up/rewrite this method.',
    'func (s *Site) processPartial(events []fsnotify.Event) (whatChanged, error) {\n\n\tevents = s.filterFileEvents(events)\n\tevents = s.translateFileEvents(events)\n\n\ts.Log.DEBUG.Printf("Rebuild for events %q", events)\n\n\th := s.h\n\n\t// First we need to determine what changed\n\n\tvar (\n\t\tsourceChanged       = []fsnotify.Event{}\n\t\tsourceReallyChanged = []fsnotify.Event{}\n\t\tcontentFilesChanged []string\n\t\ttmplChanged         = []fsnotify.Event{}\n\t\tdataChanged         = []fsnotify.Event{}\n\t\ti18nChanged         = []fsnotify.Event{}\n\t\tshortcodesChanged   = make(map[string]bool)\n\t\tsourceFilesChanged  = make(map[string]bool)\n\n\t\t// prevent spamming the log on changes\n\t\tlogger = helpers.NewDistinctFeedbackLogger()\n\t)\n\n\tcachePartitions := make([]string, len(events))\n\n\tfor i, ev := range events {\n\t\tcachePartitions[i] = resources.ResourceKeyPartition(ev.Name)\n\n\t\tif s.isContentDirEvent(ev) {\n\t\t\tlogger.Println("Source changed", ev)\n\t\t\tsourceChanged = append(sourceChanged, ev)\n\t\t}\n\t\tif s.isLayoutDirEvent(ev) {\n\t\t\tlogger.Println("Template changed", ev)\n\t\t\ttmplChanged = append(tmplChanged, ev)\n\n\t\t\tif strings.Contains(ev.Name, "shortcodes") {\n\t\t\t\tshortcode := filepath.Base(ev.Name)\n\t\t\t\tshortcode = strings.TrimSuffix(shortcode, filepath.Ext(shortcode))\n\t\t\t\tshortcodesChanged[shortcode] = true\n\t\t\t}\n\t\t}\n\t\tif s.isDataDirEvent(ev) {\n\t\t\tlogger.Println("Data changed", ev)\n\t\t\tdataChanged = append(dataChanged, ev)\n\t\t}\n\t\tif s.isI18nEvent(ev) {\n\t\t\tlogger.Println("i18n changed", ev)\n\t\t\ti18nChanged = append(dataChanged, ev)\n\t\t}\n\t}\n\n\t// These in memory resource caches will be rebuilt on demand.\n\tfor _, s := range s.h.Sites {\n\t\ts.ResourceSpec.ResourceCache.DeletePartitions(cachePartitions...)\n\t}\n\n\tif len(tmplChanged) > 0 || len(i18nChanged) > 0 {\n\t\tsites := s.h.Sites\n\t\tfirst := sites[0]\n\n\t\ts.h.init.Reset()\n\n\t\t// TOD(bep) globals clean\n\t\tif err := first.Deps.LoadResources(); err != nil {\n\t\t\treturn whatChanged{}, err\n\t\t}\n\n\t\tfor i := 1; i < len(sites); i++ {\n\t\t\tsite := sites[i]\n\t\t\tvar err error\n\t\t\tdepsCfg := deps.DepsCfg{\n\t\t\t\tLanguage:      site.language,\n\t\t\t\tMediaTypes:    site.mediaTypesConfig,\n\t\t\t\tOutputFormats: site.outputFormatsConfig,\n\t\t\t}\n\t\t\tsite.Deps, err = first.Deps.ForLanguage(depsCfg, func(d *deps.Deps) error {\n\t\t\t\td.Site = &site.Info\n\t\t\t\treturn nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn whatChanged{}, err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(dataChanged) > 0 {\n\t\ts.h.init.data.Reset()\n\t}\n\n\tfor _, ev := range sourceChanged {\n\t\tremoved := false\n\n\t\tif ev.Op&fsnotify.Remove == fsnotify.Remove {\n\t\t\tremoved = true\n\t\t}\n\n\t\t// Some editors (Vim) sometimes issue only a Rename operation when writing an existing file\n\t\t// Sometimes a rename operation means that file has been renamed other times it means\n\t\t// it\'s been updated\n\t\tif ev.Op&fsnotify.Rename == fsnotify.Rename {\n\t\t\t// If the file is still on disk, it\'s only been updated, if it\'s not, it\'s been moved\n\t\t\tif ex, err := afero.Exists(s.Fs.Source, ev.Name); !ex || err != nil {\n\t\t\t\tremoved = true\n\t\t\t}\n\t\t}\n\t\tif removed && IsContentFile(ev.Name) {\n\t\t\th.removePageByFilename(ev.Name)\n\t\t}\n\n\t\tsourceReallyChanged = append(sourceReallyChanged, ev)\n\t\tsourceFilesChanged[ev.Name] = true\n\t}\n\n\tfor shortcode := range shortcodesChanged {\n\t\t// There are certain scenarios that, when a shortcode changes,\n\t\t// it isn\'t sufficient to just rerender the already parsed shortcode.\n\t\t// One example is if the user adds a new shortcode to the content file first,\n\t\t// and then creates the shortcode on the file system.\n\t\t// To handle these scenarios, we must do a full reprocessing of the\n\t\t// pages that keeps a reference to the changed shortcode.\n\t\tpagesWithShortcode := h.findPagesByShortcode(shortcode)\n\t\tfor _, p := range pagesWithShortcode {\n\t\t\tcontentFilesChanged = append(contentFilesChanged, p.File().Filename())\n\t\t}\n\t}\n\n\tif len(sourceReallyChanged) > 0 || len(contentFilesChanged) > 0 {\n\t\tvar filenamesChanged []string\n\t\tfor _, e := range sourceReallyChanged {\n\t\t\tfilenamesChanged = append(filenamesChanged, e.Name)\n\t\t}\n\t\tif len(contentFilesChanged) > 0 {\n\t\t\tfilenamesChanged = append(filenamesChanged, contentFilesChanged...)\n\t\t}\n\n\t\tfilenamesChanged = helpers.UniqueStrings(filenamesChanged)\n\n\t\tif err := s.readAndProcessContent(filenamesChanged...); err != nil {\n\t\t\treturn whatChanged{}, err\n\t\t}\n\n\t}\n\n\tchanged := whatChanged{\n\t\tsource: len(sourceChanged) > 0 || len(shortcodesChanged) > 0,\n\t\tother:  len(tmplChanged) > 0 || len(i18nChanged) > 0 || len(dataChanged) > 0,\n\t\tfiles:  sourceFilesChanged,\n\t}\n\n\treturn changed, nil\n\n}',
    'func WebPageImageResolver(doc *goquery.Document) ([]candidate, int) {\n\timgs := doc.Find("img")\n\n\tvar candidates []candidate\n\tsignificantSurface := 320 * 200\n\tsignificantSurfaceCount := 0\n\tsrc := ""\n\timgs.Each(func(i int, tag *goquery.Selection) {\n\t\tvar surface int\n\t\tsrc = getImageSrc(tag)\n\t\tif src == "" {\n\t\t\treturn\n\t\t}\n\n\t\twidth, _ := tag.Attr("width")\n\t\theight, _ := tag.Attr("height")\n\t\tif width != "" {\n\t\t\tw, _ := strconv.Atoi(width)\n\t\t\tif height != "" {\n\t\t\t\th, _ := strconv.Atoi(height)\n\t\t\t\tsurface = w * h\n\t\t\t} else {\n\t\t\t\tsurface = w\n\t\t\t}\n\t\t} else {\n\t\t\tif height != "" {\n\t\t\t\tsurface, _ = strconv.Atoi(height)\n\t\t\t} else {\n\t\t\t\tsurface = 0\n\t\t\t}\n\t\t}\n\n\t\tif surface > significantSurface {\n\t\t\tsignificantSurfaceCount++\n\t\t}\n\n\t\ttagscore := score(tag)\n\t\tif tagscore >= 0 {\n\t\t\tc := candidate{\n\t\t\t\turl:     src,\n\t\t\t\tsurface: surface,\n\t\t\t\tscore:   score(tag),\n\t\t\t}\n\t\t\tcandidates = append(candidates, c)\n\t\t}\n\t})\n\n\tif len(candidates) == 0 {\n\t\treturn nil, 0\n\t}\n\n\treturn candidates, significantSurfaceCount\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)
# tensor([[1.0000, 0.6781, 0.3028],
#         [0.6781, 1.0000, 0.3359],
#         [0.3028, 0.3359, 1.0000]])

Training Details

Training Dataset

Unnamed Dataset

  • Size: 58,800 training samples
  • Columns: sentence_0, sentence_1, and label
  • Approximate statistics based on the first 1000 samples:
    sentence_0 sentence_1 label
    type string string float
    details
    • min: 3 tokens
    • mean: 55.73 tokens
    • max: 1024 tokens
    • min: 28 tokens
    • mean: 179.65 tokens
    • max: 1024 tokens
    • min: 1.0
    • mean: 1.0
    • max: 1.0
  • Samples:
    sentence_0 sentence_1 label
    // CASNext is a non-callback, loop-based version of CAS method.
    //
    // Usage is like this:
    //
    // var state memcached.CASState
    // for client.CASNext(vb, key, exp, &state) {
    // state.Value = some_mutation(state.Value)
    // }
    // if state.Err != nil { ... }
    func (c *Client) CASNext(vb uint16, k string, exp int, state *CASState) bool {
    if state.initialized {
    if !state.Exists {
    // Adding a new key:
    if state.Value == nil {
    state.Cas = 0
    return false // no-op (delete of non-existent value)
    }
    state.resp, state.Err = c.Add(vb, k, 0, exp, state.Value)
    } else {
    // Updating / deleting a key:
    req := &gomemcached.MCRequest{
    Opcode: gomemcached.DELETE,
    VBucket: vb,
    Key: []byte(k),
    Cas: state.Cas}
    if state.Value != nil {
    req.Opcode = gomemcached.SET
    req.Opaque = 0
    req.Extras = []byte{0, 0, 0, 0, 0, 0, 0, 0}
    req.Body = state.Value

    flags := 0
    exp := 0 // ??? Should we use initialexp here instead?
    binary.BigEndian.PutUint64(req.Extras, uint64(flags)<<32
    uint64(exp))
    }
    state.resp, state.Err = c.Send(req)
    }

    // If the response status is KEY_EEXISTS or NOT_STORED there's a conflict and we'll need to
    // get the new value (below). Otherwise, we're done (either ...
    // RestoreResourcePools restores a bulk of resource pools, usually from a backup. func (f *Facade) RestoreResourcePools(ctx datastore.Context, pools []pool.ResourcePool) error {
    defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.RestoreResourcePools"))
    // Do not DFSLock here, ControlPlaneDao does that
    var alog audit.Logger
    for _, pool := range pools {
    alog = f.auditLogger.Message(ctx, "Adding ResourcePool").Action(audit.Add).Entity(&pool)
    pool.DatabaseVersion = 0
    if err := f.addResourcePool(ctx, &pool); err != nil {
    if err == ErrPoolExists {
    if err := f.updateResourcePool(ctx, &pool); err != nil {
    glog.Errorf("Could not restore resource pool %s via update: %s", pool.ID, err)
    return alog.Error(err)
    }
    } else {
    glog.Errorf("Could not restore resource pool %s via add: %s", pool.ID, err)
    return alog.Error(err)
    }
    }
    alog.Succeeded()
    }
    return nil
    }
    1.0
    // run starts a goroutine to handle client connects and broadcast events. func (s *Streamer) run() {
    go func() {
    for {
    select {
    case cl := <-s.connecting:
    s.clients[cl] = true

    case cl := <-s.disconnecting:
    delete(s.clients, cl)

    case event := <-s.event:
    for cl := range s.clients {
    // TODO: non-blocking broadcast
    //select {
    //case cl <- event: // Try to send event to client
    //default:
    // fmt.Println("Channel full. Discarding value")
    //}
    cl <- event
    }
    }
    }
    }()
    }
    1.0
  • Loss: MultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim"
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 40
  • per_device_eval_batch_size: 40
  • fp16: True
  • multi_dataset_batch_sampler: round_robin

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: no
  • prediction_loss_only: True
  • per_device_train_batch_size: 40
  • per_device_eval_batch_size: 40
  • 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: 3
  • 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: True
  • 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: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': 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
  • hub_revision: None
  • 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
  • liger_kernel_config: None
  • eval_use_gather_object: False
  • average_tokens_across_devices: False
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: round_robin
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Epoch Step Training Loss
0.3401 500 0.256
0.6803 1000 0.1615
1.0204 1500 0.1329
1.3605 2000 0.034
1.7007 2500 0.032
2.0408 3000 0.0271
2.3810 3500 0.0081
2.7211 4000 0.0074

Framework Versions

  • Python: 3.10.12
  • Sentence Transformers: 5.0.0
  • Transformers: 4.53.1
  • PyTorch: 2.7.0+cu128
  • Accelerate: 1.7.0
  • Datasets: 3.6.0
  • Tokenizers: 0.21.2

Citation

BibTeX

Sentence Transformers

@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",
}

MultipleNegativesRankingLoss

@misc{henderson2017efficient,
    title={Efficient Natural Language Response Suggestion for Smart Reply},
    author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
    year={2017},
    eprint={1705.00652},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}