I am trying to extend huggingface DistilBertForQuestionAnswering class to add some more functionality:
class DistilBertForQuestionAnsweringCustom(DistilBertForQuestionAnswering):
I am getting following error if I try to load the pretrained model:
model = DistilBertForQuestionAnsweringCustom.from_pretrained("distilbert-base-uncased")
AttributeError: module 'DistilBertForQuestionAnsweringCustom' has no attribute 'from_pretrained'
I know that it's a novice question but it'll be helpful if someone can point me to the right direction. Just getting started with huggingface.
Related
I'm trying to make huggingface's transformer library use a model that I have downloaded that is not in the huggingface model repository.
Where does transformers look for models? Is there an equivalent of the $PATH environment variable for transformers models?
Research
This hugging face issues talks about manually downloading models.
This issue suggests that you can work around the question of where huggingface is looking for models by using the path as an argument to from_pretrained (#model = BertModel.from_pretrained('path/to/your/directory')`)
Related questions
Where does hugging face's transformers save models?
I am currently in the process of learning Laravel 5 by doing a small project. I come from CodeIgniter and have some programming experience in other languages as well.
For this project I have a few Eloquent models setup;
Exercise -> has many variations
Variation -> belongs to exercise
User -> is creator of exercise and/or variation
I am using Larasponse and have written some transformers for each entity, as I want to create a flexible API.
To use 'eager' loading I have been playing around with Fractal and the 'ParseIncludes' function, and created a ApiController that handles this for you. For each controller that extends the ApiController you can set $IncludeOptions that relate to that specific resource, and passing that to a function to get eloquent eager loaded relations.
So far it works, but I was wondering if I am doing something really stupid or if there is a better/cleaner way to implement this into the ApiController and it's child-classes..
https://gist.github.com/EdwinMeijne/1fd103fbf8f903ce58bc
Care to take a look?
I'm developing a component for Joomla 3, but I don't understand how to use the datamodel in joomla 3. Am I supposed to use the Legacy-classes? Will these not be deprecated after a while?
I see most of the joomla components are using the class JModelList, which extends JModelLegacy. To load such a class I can use
JModelLegacy::getInstance('classname');
but is there a way to do this without using legacy-classes? I would think that the word legacy implies that the code hase been replace for something newer/better/hotter? Please enlighten me if anyone knows better ...
PS: I also asked this question on the Joomla - forum, but got no replies (http://forum.joomla.org/viewtopic.php?f=706&t=837707)
regards Jonas
I tend to use JModelList and JModelForm because this way PHP error logging will notify during code execution if your class has failed to meet some of its "contractual" class obligations from any of the parent/super classes.
The answer depends on yourself, and there is really no "wrong" answer here. Pick the method which makes the most sense to you and go with it.
** EDIT **
You can always load and instantiate a model class like so, using User's registration model as example.
JLoader::register('UsersModelRegistration', JPATH_ROOT . '/components/com_users/models/registration.php');
$model = new UsersModelRegistration();
Error: Class 'Ibooks_Controller' not found in/Users/winas/workspace/media_admin/media_books/application/tasks/sample.php
Class that produces error: class Sample_Task extends Ibooks_Controller
Ibooks_Controller path: /Users/winas/workspace/media_admin/media_books/application/controllers/ibooks.php
How can I properly call the function that Ibooks_controller have inside of sample.php
you can't extend a Controller when making a Task. And more importantly, it would be something really bad to do.
I don't know what it is that you're trying to do, but if you want to access any data, you should use models and/or libraries for that.
Besides that, a short explanation on why the class is not found.
Laravel only autoloads files/classes that are in the "models" and "libraries" directories. (There might be more)
Controllers are only loaded when a Route request that controller to be loaded. And will only then search for which controller to load.
If you need to load classes that are not in one of the standard auto-loaded classes, you can load it using the Laravel Autoloader class:
http://three.laravel.com/docs/loading
How do make CodeIgniter correctly load controller classes if I want to name them [name]_Controller rather than just [name]?
You would have to write your own router-class, in the documentation is a great explanation for that task!
This could be a good starting point:
https://github.com/EllisLab/CodeIgniter/blob/develop/system/core/Router.php#L394