Is there a like `datacollator` code can apply n-grams masked to masked Language Model using pytorch? - bert-language-model

I want apply n-grams masked to masked Language Model in pre-train model using pytorch, Is there source code about it? or Just I must to Implementation it?
This is huggingface's code about datacollator.
https://github.com/huggingface/transformers/blob/master/src/transformers/data/data_collator.py
Thanks very much!

Related

can't use dea function of Benchmarking package in R

I'm using Benchmarking package to run a model of data envelopment analysis using dea function on it. In addition, I'm using nonparaeff package, for partial frontier, which has a function called dea too. This similarity in name function produces this "error":
Attaching package: ‘nonparaeff’
The following object is masked from ‘package:Benchmarking’:
So, is it possible to use both packages at the same time or not?
Yes, you can use both packages.
Attaching package: ‘nonparaeff’ The following object is masked from ‘package:Benchmarking’:
This error message basically means, that the package you loaded last (in this case nonparaeff) masks functions from Benchmarking.
The first thing to mention is:
All other functions without naming conflicts will work as expected.
The second thing to take care of is:
When you just call dea() in your code now, you will call the function from the package last loaded. (because the other package's dea() function is masked by this function)
But, to be sure to call the right function you can just write the functions calls like this : Benchmarking::dea() and nonparaeff::dea().
By specifying packagename::funtionname() you make sure to call exactly the function from the specified package. It is not as convenient as calling just dea(), but in case of functions with the same name, I would actually use this for both functions. (to prevent mistakes)
I myself quite often call my functions with packagename::funtionname() - it avoids errors and another positive is, you directly know by looking at the code, from which package a function is.

R package: is there a method to generate a diagram of methods and dependencies in a package?

I'm writing a package in R, defining a few S4 classes with inheritance and associated methods. I'd like to know if there's a package or method that would allow to automatically generate a flowchart summarizing classes, attributes and methods? Like some sort of ERD diagram?
Thank you.

Is there a way to always check for a function within one specific package before looking through the rest of the search path?

I'm working on writing an R package that masks several functions from various tidyverse packages. For my package to work correctly, I need the masked functions within it to ALWAYS be called over the functions from tidyverse. Because of the way the package is designed, just using my_package::function will NOT work for solving this problem.
Is there a way to force a package to always be second in the search() path? If not, is there a way to block specific functions from being run when my package is installed (for instance, is there somewhere I can write in my package that readr::read_csv should never be used over my masked read_csv?).

Better plotting of tree object

I am trying to find a better way to plot a "tree" object from the tree package in R. I realize that there are good plotting tools for rpart package trees, but I am creating my tree object from scratch, therefore a "tree" object from the tree package is better suited for my purposes.
My question is, does anyone know of a better way to plot "tree" objects than plot?
I am trying to include the distribution of values, square blocks for the leaf nodes, majority class, etc.
I could've sworn there was a package that could take a "tree" object as the argument but I can't seem to find it.
This is for a classification tree.

Convert party object to pmml

I am currently trying to convert a decision tree created using the R package partykit (party object) to a pmml-format. Are there packages that allow for this conversion? I am aware of the existance of the pmml-package, but this only supports rpart objects, created using the R package rpart. As I want to create decision trees myself and not retrieve them from a dataset, simply using rpart instead of partykit is not a solution.
Thank you for your suggestions,
Niels
At the moment the partykit package does not provide this feature. The package has many converters from other objects to party objects, including a converter from PMML. However, there are not many options to convert from party objects to other classes. A PMML export would certainly nice to have (at least for the special case of constparty objects) but so far I didn't look at what needs to be done for this.

Resources