teleren/devto huggingface dataset:
Introducing LoadTime: Bringing Clarity to HuggingFace Model Loading Times
Tags: python, hugging, face, llm
Published: 2023-06-02 00:31:50

---
title: Introducing LoadTime: Bringing Clarity to HuggingFace Model Loading Times
published: true
description: Display a progress bar for long processes with uncertain end times
tags: python,hugging,face,llm
cover_image: https://riversun.github.io/loadtime/loadtime_cover.png
# Use a ratio of 100:42 for best results.
# published_at: 2023-06-02 00:00 +0000
---

Are you tired of the uncertainty of how long it takes to load large-scale pre-trained language models, such as those from HuggingFace, into GPU or CPU memory? Do you find yourself gazing blankly at a static screen, not knowing when the loading will finally conclude? Let me present you with the solution - LoadTime.

<img src="https://riversun.github.io/loadtime/loadtime_std.gif">


LoadTime is a library that I've developed to tackle this very problem. It provides a progress bar during the memory loading process, bringing an end to your uncertainty. Now, let's dive a little deeper into how it works and what it has to offer.


While HuggingFace's models do provide progress indications during the download phase, they leave you in the dark during memory loading. This is where LoadTime comes into play. The mechanism is simple yet effective: During the initial load, LoadTime caches the total loading time. When the same model is loaded subsequently, LoadTime uses this cached time as a reference to display a progress bar.

Unlike other progress display libraries like **tqdm** , which require a known total count beforehand, LoadTime is designed for situations where the total is unknown. It provides real-time updates based on past data, making it a versatile tool for your tasks.

## Example

```
pip install loadtime
```

Here is a simple example of how to use the LoadTime package:

In order to use it, you simply need to wrap the model loading part with LoadTime. It's as easy as that!


```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from loadtime import LoadTime

model_path = "togethercomputer/RedPajama-INCITE-Chat-3B-v1"


# model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.float16)


model = LoadTime(name=model_path,
                 fn=lambda: AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.float16))()


tokenizer = AutoTokenizer.from_pretrained(model_path) # important. load tokenizer after model.

```


Thanks.
Stepping Into the Future: AI in Your Daily Routine
Tags: ai, machinelearning, algorithms, data
Published: 2023-06-02 00:16:08

Once upon a "byte", there was a world where people had to manually switch on lights, check the weather on an actual television, and God forbid, wake up to a physical, ear-shattering alarm clock. Oh, the horror! But thanks to the magic of Artificial Intelligence (AI), our daily lives have morphed into an episode of The Jetsons, minus the flying cars (we're still working on that).

**Machine Learning or Machine Earning?**

Do you remember your favorite time of day in school? Mine was always 3 PM, not because I was an academic savant, but because that's when the bell rang and it was time to go home. AI is a bit like a school kid, always learning but unlike most students, it doesn’t dread Mondays or math classes. Instead, it gobbles up data, learns from patterns, makes predictions, and sometimes even proves your mom wrong when she says, "It's going to rain, carry an umbrella!" If an AI was a student, it would definitely be the teacher's pet.

**A SIRI-ous Relationship**

Alexa, Siri, Google Assistant, or Cortana, we've all got a favorite, haven't we? Don't deny it. You've asked one of them to sing, tell a joke, or even flirted with them, haven't you? It's okay, we're all friends here. These voice-activated AIs have become our personal assistants, DJs, and sometimes therapists. They know our favorite songs, remind us of our anniversary (you owe them, fellas!), and are always ready with a dad joke when we're feeling blue.

**What's the Buzz about Smart Homes?**

Gone are the days when you needed to get off the couch to control, well, anything at home. From smart bulbs that can mimic sunset hues to match your romantic dinner, to intelligent refrigerators that remind you to buy milk when you're at the grocery store, the future is indeed here. Now, if only they could invent a smart vacuum that could also walk the dog.

**Your Personal Health AI-d**

Fitness trackers, smartwatches, AI yoga mats – welcome to your home gym 2.0. These smart gadgets nudge you off the couch, motivate you to burn those pesky calories, and even monitor your sleep. Now, if we could just train them to virtually slap that donut out of our hand...

**AI in the Workplace**

AI is also playing a growing role in the workplace. It helps us schedule meetings, filter spam emails, and even automate mundane tasks. But worry not, it doesn't look like robots are taking over our jobs anytime soon. However, Bob from accounting might need to watch out – AI is getting pretty good at number crunching.

So there you have it, folks. A sneak peek into the AI-powered future that's already upon us. To all the technophobes out there, it might seem daunting, but remember, technology is like an old dog, it can't learn new tricks unless you teach it. So embrace the change, and remember, "A byte of AI keeps the chaos away".

If you have any exciting AI experiences or if your smart fridge has ever saved your day, do share your stories in the comment section below. Or better yet, ask Siri to write it for you!
100 Days Coding Challenge - Day 13: FreeCodeCamp JavaScript Algorithms and Data Structures
Tags: javascript, programming, webdev, 100daysofcode
Published: 2023-06-01 23:49:05

## Day 13

I finish the section of Regular Expressions, it's not much but, I'm now in my laptop while I'm installing windows and kali Linux on my PC. My university will ask for use Linux and also, I want to use it, probably I will learn etic hacking. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x928zi4gd5xmxgqnkffx.png)
Dia 3 - #100DaysOfSwift
Tags: todayilearned, swift, ios
Published: 2023-06-01 23:05:17

## Operadores de comparação
Servem pra comparar dados num geral, podem ser usado pra dados numéricos, texto, etc.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ghgr131ahwwnwnbj5tyd.png)

---

## Operador ternário
É muito útil pra quando se quer fazer algo específico se algo for verdadeiro ou falso de forma bem mais enxuta do que usando um if/else.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jubjk3wh2pcmkgwi0vbv.png)

Nesse exemplo o valor resultante do ternário é atribuído à variável z:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8rccbwd4ygdlwaebw3k5.png)

---

## Switch
Se tiver que fazer várias condicionais usando um mesmo valor como parâmetro, fica mais fácil usar um switch do que um if/else.

Caso queira que mesmo após cair num case ele também execute o próximo é só colocar a keyword fallthrough.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r2x07vz39tol8np0znyi.png)

---

## Operadores de range
No swift existem duas formas de representar um range.
`..<` exclui o último número do range:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a0oc8496ymill6i6qsyv.png)


`...` inclui todos os números que estão no range.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/szlxl5duwhyadnvuay3p.png)
A Little Panic in Zig
Tags: zig, rust, programming
Published: 2023-06-01 22:21:03

In Rust there are several ways to handle errors that come from the `Result` and `Option` types. A common way to get the inner value is using the `unwrap` method that either returns the value or panics the program. So how would we implement this function in Zig? Well there are several methods of handling errors in Zig, to keep ours simple we will use an `if/else` statement. 

Let's start with by creating a file called `unwrap.zig`, and import the standard library and assign it to the constant `std`. 

```{zig}
// unwrap.zig 
const std = @import("std");
```

We will be using compile time generics in our function, you may also use function type inference if you'd like. 

What we expect is a type for our generic `T`, and an error set in the form `anyerror!T` where we will return the value `T`. 

```{zig}
pub fn unwrap(comptime T: type, val: anyerror!T) T {}
```

Inside of the function we will use an `if/else` statement where the `if` statement will handle a successful value and the `else` statement handles the error. In these statements we will need to capture the values using the `| |` syntax as shown: 

```{zig}
if(val) |value|{
   return value;
} else |err|{
   std.debug.panic("Panicked at Error: {any}",.{err});
}
```

As you can see in our `if` block we return the successful value we capture as the variable `value`, while in the `else` block, we capture the error as the variable `err` and print it using `std.debug.panic`. 

To test out our function, I have create an error type called `MathError` with one field called `DivideByZero`. This is similar to an enum implementing the `Error` trait in Rust. 

```{zig}
const MathError = error{
    DivideByZero
};
```

Now we can create a function called `divide` which checks if the denominator is zero, and if it is we return the divide by zero error. 

```{zig}
fn divide(comptime T: type, a: T, b: T) MathError!T{
    if (b == 0){
        return MathError.DivideByZero;
    } else {
        return a / b;
    }
}
```

Lastly we will create our `main` function where we will try this with a successful result and a result doomed to panic. 

If we run our program we get the following result: 

```{bash}
$ zig build-exe unwrap.zig 
$ ./unwrap
Result: 6.71641826e-01
thread 52729 panic: Panicked at Error: error.DivideByZero
...
```

This article was just a fun experiment to try something I use in Rust and try it in Zig. Like in Rust, panicking isn't a good way to handle errors, and in most cases the `try` keyword in Zig is enough.
"Overcoming Recruiter Silence: Insights from Industry Connections and Building a Supportive Network for Job Seekers"
Tags: discuss, community, jobsearching, career
Published: 2023-06-01 21:49:58

**I know firsthand the frustration that comes with not hearing back from recruiters.** After having conversations with my recruiter friends, I've made a few observations. They are overwhelmed with their workload, which explains the lack of communication. Sometimes, they must take down job descriptions from their website after posting them for one day. They also said they are getting more applications because of the increased pool of talent in the market. 

Despite these challenges, I've realized that people are still getting jobs. It's a matter of resilience and perseverance. It's essential to build structures and communities around myself that provide support and encouragement to keep going.

## What has helped me? 

- Connecting with other job seekers going through similar experiences. We can find solace and motivation by sharing our journeys and supporting each other.
- Seeking guidance from mentors in my field can offer valuable insights and advice.
- Asking for help. Share what you are looking for with friends and loved ones. Referrals often help your applications to stand out. 

What has helped you? We can do this together!
Announcing LagoonCon!
Tags: event, community, conference
Published: 2023-06-01 21:42:16

Join us for the first-ever LagoonCon in Pittsburgh,
June 6, 2023! 

Welcome to LagoonCon! If you’re a developer looking for an easier way to deliver applications, then look no further. Lagoon is an open source ZeroOps application delivery platform (created by developers) to make the lives of fellow developers easier.

Schedule - June 6, 2023

6:00 PM - 6:30 PM EDT: Welcome Drinks

6:30 PM - 8:30 PM EDT: Talks and time for questions

8:30 PM - 9:00 PM EDT: Heavy hors d'oeuvres, drinks, and socializing

Register here: https://www.amazee.io/events/lagooncon-2023
Difference between Business Intelligence and Data Warehouse with Big Data 🌟
Published: 2023-06-01 21:13:47

# What is Business Intelligence? 🧠
Business intelligence (BI) is the process of analyzing data and presenting it in a way that helps people make better decisions. BI can use various tools and techniques, such as dashboards, reports, charts, graphs, and more. BI can help you answer questions like:

- How are my sales doing this month? 📈
- Which products are the most popular among my customers? 🛒
- How can I improve my marketing strategy? 📣

# What is Data Warehouse? 🏬
Data warehouse (DW) is a system that stores and organizes data from different sources, such as databases, files, web pages, etc. DW can help you integrate and consolidate data from various formats and locations, and make it available for analysis. DW can help you answer questions like:

- What are the trends and patterns in my data over time? ⏳
- How does my data compare across different segments or regions? 🌎
- How can I ensure the quality and consistency of my data? ✅

# What is Big Data? 🐘
Big data is a term that refers to data that is too large, complex, or diverse to be handled by traditional methods. Big data can come from various sources, such as social media, sensors, web logs, etc. Big data can help you answer questions like:

- What are the hidden insights and opportunities in my data? 🔎
- How can I use my data to create new products or services? 💡
- How can I use my data to predict future outcomes or behaviors? 🔮

# How are they different? 🤔
Business intelligence, data warehouse, and big data are related concepts, but they are not the same. Here are some of the differences between them:

| BI | DW | Big Data |
| --- | --- | --- |
| Focuses on analyzing data and presenting it in a user-friendly way | Focuses on storing and organizing data from different sources | Focuses on handling data that is too large, complex, or diverse for traditional methods |
| Uses tools and techniques such as dashboards, reports, charts, graphs, etc. | Uses tools and techniques such as ETL (extract, transform, load), OLAP (online analytical processing), etc. | Uses tools and techniques such as Hadoop, Spark, NoSQL, etc. |
| Helps people make better decisions based on data | Helps people integrate and consolidate data from various formats and locations | Helps people discover hidden insights and opportunities in data |

# Conclusion 🎉
Business intelligence, data warehouse, and big data are important concepts in the field of data science. They can help you collect, store, organize, analyze, and present your data in a meaningful way. They can also help you improve your business performance and create value from your data.

I hope you enjoyed this article and learned something new. If you have any questions or feedback, please let me know in the comments below. Thank you for reading! 😊
React Native Notes Download Complete Learn React Native
Published: 2023-06-01 20:10:26

In the dynamic world of mobile app development, React Native has emerged as a game-changer, empowering developers to build captivating applications for both iOS and Android platforms using a single codebase. In this blog post, I’ll share my journey and insights into harnessing the power of React Native, from learning the fundamentals to successfully deploying my first app. Join me as we delve into cross-platform mobile development and discover its limitless possibilities.

## React Native Notes


{% embed https://progexpo.medium.com/react-native-notes-download-learn-mobile-app-development-2023-4b3c45f27224 %}
Pebl Release 0.0.5
Tags: pebl, devops, cloud, infrastructureascode
Published: 2023-06-01 19:56:32

## Quick Summary

Release 0.0.5 has support for streaming production logs using the CLI and updates to the Go package.

## Longform

### pebl CLI

Previously the only way to look at logs from the cloud runtime was to go to our [console](https://www.pebl.io/console/logs). The latest pebl CLI now supports the command `pebl logs`, which will stream those logs so that you can see them on your terminal.

```
$ ./pebl logs
[06/01 12:43:49] foo
[06/01 12:44:34] bar
[06/01 12:44:35] hello, world!
```

To upgrade you can follow the [setup steps](https://docs.pebl.io/setup).

### Go SDK

Previously our Go package was structured such that the pebl bindings were under the `sdk` package, meaning that you had to import the package using `github.com/peblcloud/go/sdk`.

Based on user feedback we have decided to move all the bindings to the root level, and to change the package name to `pebl`. In short you can now do this:

```go
package main

import (
    "net/http"
    "github.com/peblcloud/go"
)

func main() {
    service := http.NewServeMux()

    service.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("hello, world!\n"))
    })

    pebl.Service(service, "svc.internal")
}
```

To upgrade you can run `go get github.com/peblcloud/go@v0.0.5` in your Go projects.
How to use the Apache AGE's Cypher Query Language
Tags: apacheage, graphql, postgres, database
Published: 2023-06-01 19:45:26

The examples provided in the documentation demonstrate how to use the Apache AGE's Cypher Query Language to interact with graph data stored in PostgreSQL. Here are some examples:

- Get all vertices: This query returns all vertices in the graph.

```
SELECT * FROM cypher('graph_name', $$
MATCH (v)
RETURN v
$$) as (v agtype);
```

The output will be something like:
```
{id: 0; label: ‘Person’; properties: {name: ‘Charlie Sheen’}}::vertex   
{id: 1; label: ‘Person’; properties: {name: ‘Martin Sheen’}}::vertex   
{id: 2; label: ‘Person’; properties: {name: ‘Michael Douglas’}}::vertex   
{id: 3; label: ‘Person’; properties: {name: ‘Oliver Stone’}}::vertex   
{id: 4; label: ‘Person’; properties: {name: ‘Rob Reiner’}}::vertex   
{id: 5; label: ‘Movie’; properties: {name: ‘Wall Street’}}::vertex   
{id: 6; label: ‘Movie’; properties: {title: ‘The American President’}}::vertex
```

- Get all vertices with a label: This query returns all vertices with a specific label. In this case, it returns all movies in the database.

```
SELECT * FROM cypher('graph_name', $$
MATCH (movie:Movie)
RETURN movie.title
$$) as (title agtype);
```
The output will be something like:
```
title  
‘Wall Street’   
‘The American President’
```

- Find related vertices: This query returns all vertices related to a specific vertex, regardless of the type or direction of the edge. Here, it returns all the movies directed by 'Oliver Stone'.
```
SELECT * FROM cypher('graph_name', $$
MATCH (director {name: 'Oliver Stone'})-[]-(movie)
RETURN movie.title
$$) as (title agtype);
```

The output will be something like:
```
title  
‘Wall Street’
```

- Find vertices connected by a specific type of edge: This query finds all vertices connected by a specific type of edge. It returns all actors that acted in 'Wall Street'.

```
SELECT * FROM cypher('graph_name', $$
MATCH (:Movie {title: 'Wall Street'})<-[:ACTED_IN]-(actor)
RETURN actor.name
$$) as (actors_name agtype);
```

The output will be something like:
```
actors_name  
‘Charlie Sheen’   
‘Martin Sheen’   
‘Michael Douglas’
```

### References

- [Docs](http://age.apache.org/)
- [Source Code](http://github.com/apache/age)
The new Terraform Cloud pricing model is so expensive! Or is it?
Tags: terraform
Published: 2023-06-01 19:36:25

Terraform Cloud recently presented a new pricing model. Previously you paid $20 per user per month, for the **team tier**. Now you pay $0.00014 per managed resource per hour. Initially it is difficult to say if this is better or worse for you and your current environment.

Before we dig into the answer, lets first stop and appreciate two important points:

1. The first 500 resources are free. This means that if you have 500 or less resources, you don't pay anything. If you go above 500 resources, you pay only for those resources. The first 500 are always free.
1. With the new pricing model we also get access to features that were previously only available for the priced tiers. This is great news to those who were already using a free tier of Terraform Cloud. They can continue to use a free Terraform Cloud (as long as the number of resources are less than 500), and enjoy premium features such as run tasks and sentinel policy integration.

Let's move back to the topic of pricing. If the new pricing model is expensive or not depends on how many resources you are currently deploying through Terraform Cloud, and how many users you currently have in your Terraform Cloud environment. 

The table below illustrates the situation nicely. On the x-axis (left-right) we have the number of active users, and on the y-axis (up-down) we have the number of resources. The number in the table is the **price per user per month**. A green box means we pay less than what we previously paid, a red box means we pay more than we previously paid. A white box simply means we pay an equal amount. Take a look:

![Price for number of resources and per user](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1iuvqs034xayu5lkohvq.png)

Let us imagine two different possible scenarios:

1. In scenario one we are two developers managing a large number of resources. We are the two super-heroes of infrastructure-as-code in our company. We have currently deployed 3000 resources throughout all our environments. Unfortunately this new pricing model means we will pay **$151 per user per month**. Not good!
1. In scenario two we are 15 developers split into multiple teams. Each team takes care of their own environment. In total we have 2600 resources. With the new pricing model we pay **$17 per user per month**. Nice!

Which scenario is most common? In my personal experience scenario two is more common, but more reasonably there would be **more users** and **less resources** than what that scenario has. The first scenario might be common, but if you find yourself in that scenario you should ask yourself why that is. Maybe it is high time to onboard additional users into your Terraform Cloud environment?

Let me know what you think!
Bottle+Sqlite
Published: 2023-06-01 19:10:50

A few more words about Bottle. After enabling a sqlite extension, you can easily include a specified keyword as a view argument. Like:

```python
app = bottle.Bottle()
db_plugin = bottle_sqlite.Plugin(dbfile='./test.db', keyword="db")
app.install(db_plugin)

@app.route("/")
def main(db):
    ....
```

It works perfect... Until you decide to show the view for authorized users only. And this
```python
@bottle.auth_basic()
def save_post(db):
    ...
```
will cause 
```
TypeError("main() missing 1 required positional argument: 'db'")
```
This is a [known issue](https://github.com/bottlepy/bottle-sqlite/issues/21), which still wasn't solved on the plugin level. So, again [workarounds](https://github.com/storvus/effective-pancake/blob/bottle/db/bottle_sqlite.py)

The only change here is:
```python
params = inspect.signature(_callback).parameters
if keyword not in params:
    return callback
```
instead of
```python
argspec = inspect.getargspec(_callback)
```