Fuseki dataset becomes too slow with reasoner OWLMicro - sparql

Recently I have applied the OWL Micro reasoner to my Fuseki dataset but now when I query that dataset some queries timeout and others are really slow. However, I cannot change the reasoner once I need it for some of the queries. An approach I have seen are too create two datasets with the same data, one with inference with the OWL reasoner and the other with the raw data. Is that the best approach to follow or is there a better solution?

Related

Does knowledge distillation have an ensemble effect?

I don't know much about knowledge distillation.
I have a one question.
There is a model with showing 99% performance(10class image classification). But I can't use a bigger model because I have to keep inference time.
Does it have an ensemble effect if I train knowledge distillation using another big model?
-------option-------
Or let me know if there's any way to improve performance than this.
enter image description here
The technical answer is no. KD is a different technique from ensembling.
But they are related in the sense that KD was originally proposed to distill larger models, and the authors specifically cite ensemble models as the type of larger model they experimented on.
Net net, give KD a try on your big model to see if you can keep a lot of the performance of the bigger model but with the size of the smaller model. I have empirically found that you can retain 75%-80% of the power of the a 5x larger model after distilling it down to the smaller model.
From the abstract of the KD paper:
A very simple way to improve the performance of almost any machine learning algorithm is to train many different models on the same data and then to average their predictions. Unfortunately, making predictions using a whole ensemble of models is cumbersome and may be too computationally expensive to allow deployment to a large number of users, especially if the individual models are large neural nets. Caruana and his collaborators have shown that it is possible to compress the knowledge in an ensemble into a single model which is much easier to deploy and we develop this approach further using a different compression technique. We achieve some surprising results on MNIST and we show that we can significantly improve the acoustic model of a heavily used commercial system by distilling the knowledge in an ensemble of models into a single model. We also introduce a new type of ensemble composed of one or more full models and many specialist models which learn to distinguish fine-grained classes that the full models confuse. Unlike a mixture of experts, these specialist models can be trained rapidly and in parallel.
https://arxiv.org/abs/1503.02531

How can I implement model parallelism on a Graphcore IPU?

I’ve managed to port a version of my TensorFlow model to a Graphcore IPU and to run with data parallelism. However the full-size model won’t fit on a single IPU and I’m looking for strategies to implement model parallelism.
I’ve not had much luck so far in finding information about model parallelism approaches, apart from https://www.graphcore.ai/docs/targeting-the-ipu-from-tensorflow#sharding-a-graph in the Targeting the IPU from TensorFlow guide, in which the concept of sharding is introduced.
Is sharding the recommended approach for splitting my model across multiple IPUs? Are there more resources I can refer to?
Sharding consists in partitioning the model across multiple IPUs so that each IPU device computes part of the graph. However, this approach is generally recommended for niche use cases involving multiple models in a single graph e.g. ensembles.
A different approach to implement model parallelism across multiple IPUs is pipelining. The model is still split into multiple compute stages on multiple IPUs; the stages are executed in parallel and the outputs of a stage are the inputs to the next one. Pipelining ensures improved utilisation of the hardware during execution, which leads to better efficiency and performance in terms of throughput and latency, if compared to sharding.
Therefore, pipelining is the recommended method to parallelise a model across multiple IPUs.
You can find more details on pipelined training in this section of the Targeting the IPU from TensorFlow guide.
A more comprehensive review of those two model parallelism approaches is provided in this dedicated guide.
You could also consider using IPUPipelineEstimator : it is a variant of the IPUEstimator that automatically handles most aspects of running a (pipelined) program on an IPU. Here you can find a code example showing how to use the IPUPipelineEstimator to train a simple CNN on the CIFAR-10 dataset.

Which model (GPT2, BERT, XLNet and etc) would you use for a text classification task? Why?

I'm trying to train a model for a sentence classification task. The input is a sentence (a vector of integers) and the output is a label (0 or 1). I've seen some articles here and there about using Bert and GPT2 for text classification tasks. However, I'm not sure which one should I pick to start with. Which of these recent models in NLP such as original Transformer model, Bert, GPT2, XLNet would you use to start with? And why? I'd rather to implement in Tensorflow, but I'm flexible to go for PyTorch too.
Thanks!
It highly depends on your dataset and is part of the data scientist's job to find which model is more suitable for a particular task in terms of selected performance metric, training cost, model complexity etc.
When you work on the problem you will probably test all of the above models and compare them. Which one of them to choose first? Andrew Ng in "Machine Learning Yearning" suggest starting with simple model so you can quickly iterate and test your idea, data preprocessing pipeline etc.
Don’t start off trying to design and build the perfect system.
Instead, build and train a basic system quickly—perhaps in just a few
days
According to this suggestion, you can start with a simpler model such as ULMFiT as a baseline, verify your ideas and then move on to more complex models and see how they can improve your results.
Note that modern NLP models contain a large number of parameters and it is difficult to train them from scratch without a large dataset. That's why you may want to use transfer learning: you can download pre-trained model and use it as a basis and fine-tune it to your task-specific dataset to achieve better performance and reduce training time.
I agree with Max's answer, but if the constraint is to use a state of the art large pretrained model, there is a really easy way to do this. The library by HuggingFace called pytorch-transformers. Whether you chose BERT, XLNet, or whatever, they're easy to swap out. Here is a detailed tutorial on using that library for text classification.
EDIT: I just came across this repo, pytorch-transformers-classification (Apache 2.0 license), which is a tool for doing exactly what you want.
Well like others mentioned, it depends on the dataset and multiple models should be tried and best one must be chosen.
However, sharing my experience, XLNet beats all other models so far by a good margin. Hence if learning is not the objective, i would simple start with XLNET and then try a few more down the line and conclude. It just saves time in exploring.
Below repo is excellent to do all this quickly. Kudos to them.
https://github.com/microsoft/nlp-recipes
It uses hugging face transformers and makes them dead simple. 😃
I have used XLNet, BERT, and GPT2 for summarization tasks (English only). Based on my experience, GPT2 works the best among all 3 on short paragraph-size notes, while BERT performs better for longer texts (up to 2-3 pages). You can use XLNet as a benchmark.

What is better between tf.data.dataset and tf.train.string_input_producer for large scale dataset?

everyone.
Now, I am dealing with a large scale dataset, and I am new for constructing large scale dataset. I read lots of materials, and find that it has two methods:1. tf.train.string_producer 2. tf.data.dataset.
I am not certain about what is better, I think tf.train.string_producer is from the previous version and not optimized well, is it right? or is there a better method to construct a large scale dataset?
Thank you !!

can property graph be transformed into a RDF dataset?

We know that neo4j and Titan use property graph as their data model, which is more complicate and flexible than RDF. However, my team is building a graph database named gStore which is based on RDF datasets.
gStore can not support N-Quads or property graph because it can not deal with edges which have properties besides its label.
Below is a RDF dataset:
<John> <height> "170"
<John> <play> <football>
Below is a N-Quads dataset:
<John> <height> "170" "2017-02-01"
<John> <play> <football> "2016-03-04"
You can see that property graph is more general and can represent more relations in real life. However, RDF is more simple and our system is based on it. It is really hard to change the whole system's data model. Is there any way to transform a property graph into a RDF graph? If so, how to do it?
If the data model is well transformed, how can we query it? SPARQL language is used to query the RDF dataset, and neo4j has designed a Cypher language to query their property graph. But when we transform a property graph into a RDF graph, how can we query it?
RDF is a mechanism to serialize graph data. You can store your data in Neo4j as a property graph, query it using cypher, and serialize it automatically as RDF for data exchange and interoperability.
Check out the neosemantics plugin for Neo4j. It does exactly what you describe and more.
In the particular case you mention of properties in relationships, which RDF does not support, neosemantics will use RDF-star to avoid data loss during import/export.